use ::libc;
extern "C" {
    pub type event_base;
    pub type evbuffer;
    pub type bufferevent_ops;
    pub type args;
    pub type tmuxpeer;
    pub type hyperlinks;
    pub type screen_write_cline;
    pub type screen_sel;
    pub type screen_titles;
    pub type environ;
    pub type options;
    pub type format_tree;
    pub type screen_write_citem;
    pub type cmds;
    pub type tty_key;
    pub type tty_code;
    pub type format_job_tree;
    pub type control_state;
    pub type cmdq_list;
    pub type options_entry;
    pub type paste_buffer;
    fn __b64_pton(_: *const libc::c_char, _: *mut libc::c_uchar, _: size_t) -> libc::c_int;
    fn __b64_ntop(
        _: *const libc::c_uchar,
        _: size_t,
        _: *mut libc::c_char,
        _: size_t,
    ) -> libc::c_int;
    fn strtol(_: *const libc::c_char, _: *mut *mut libc::c_char, _: libc::c_int) -> libc::c_long;
    fn free(_: *mut libc::c_void);
    fn bsearch(
        __key: *const libc::c_void,
        __base: *const libc::c_void,
        __nmemb: size_t,
        __size: size_t,
        __compar: __compar_fn_t,
    ) -> *mut libc::c_void;
    fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int;
    fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) -> libc::c_int;
    fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char;
    fn strpbrk(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char;
    fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void;
    fn strsep(__stringp: *mut *mut libc::c_char, __delim: *const libc::c_char)
        -> *mut libc::c_char;
    fn strlen(_: *const libc::c_char) -> libc::c_ulong;
    fn event_add(ev: *mut event, timeout: *const timeval) -> libc::c_int;
    fn event_del(_: *mut event) -> libc::c_int;
    fn event_set(
        _: *mut event,
        _: libc::c_int,
        _: libc::c_short,
        _: Option<unsafe extern "C" fn(libc::c_int, libc::c_short, *mut libc::c_void) -> ()>,
        _: *mut libc::c_void,
    );
    fn evbuffer_new() -> *mut evbuffer;
    fn evbuffer_free(buf: *mut evbuffer);
    fn evbuffer_get_length(buf: *const evbuffer) -> size_t;
    fn evbuffer_add(buf: *mut evbuffer, data: *const libc::c_void, datlen: size_t) -> libc::c_int;
    fn evbuffer_drain(buf: *mut evbuffer, len: size_t) -> libc::c_int;
    fn bufferevent_write(
        bufev: *mut bufferevent,
        data: *const libc::c_void,
        size: size_t,
    ) -> libc::c_int;
    fn strtonum(
        _: *const libc::c_char,
        _: libc::c_longlong,
        _: libc::c_longlong,
        _: *mut *const libc::c_char,
    ) -> libc::c_longlong;
    fn xmalloc(_: size_t) -> *mut libc::c_void;
    fn xcalloc(_: size_t, _: size_t) -> *mut libc::c_void;
    fn xrealloc(_: *mut libc::c_void, _: size_t) -> *mut libc::c_void;
    fn xstrdup(_: *const libc::c_char) -> *mut libc::c_char;
    fn xstrndup(_: *const libc::c_char, _: size_t) -> *mut libc::c_char;
    fn xvasprintf(
        _: *mut *mut libc::c_char,
        _: *const libc::c_char,
        _: ::core::ffi::VaList,
    ) -> libc::c_int;
    static mut global_options: *mut options;
    fn getversion() -> *const libc::c_char;
    fn paste_buffer_data(_: *mut paste_buffer, _: *mut size_t) -> *const libc::c_char;
    fn paste_get_top(_: *mut *const libc::c_char) -> *mut paste_buffer;
    fn paste_add(_: *const libc::c_char, _: *mut libc::c_char, _: size_t);
    fn notify_pane(_: *const libc::c_char, _: *mut window_pane);
    fn options_get_only(_: *mut options, _: *const libc::c_char) -> *mut options_entry;
    fn options_get_number(_: *mut options, _: *const libc::c_char) -> libc::c_longlong;
    fn options_set_number(
        _: *mut options,
        _: *const libc::c_char,
        _: libc::c_longlong,
    ) -> *mut options_entry;
    fn options_remove_or_default(
        _: *mut options_entry,
        _: libc::c_int,
        _: *mut *mut libc::c_char,
    ) -> libc::c_int;
    fn alerts_queue(_: *mut window, _: libc::c_int);
    static mut clients: clients;
    fn server_redraw_window_borders(_: *mut window);
    fn server_status_window(_: *mut window);
    fn screen_write_collect_add(_: *mut screen_write_ctx, _: *const grid_cell);
    fn screen_write_carriagereturn(_: *mut screen_write_ctx);
    fn screen_write_linefeed(_: *mut screen_write_ctx, _: libc::c_int, _: u_int);
    fn grid_set_tab(_: *mut grid_cell, _: u_int);
    fn grid_get_cell(_: *mut grid, _: u_int, _: u_int, _: *mut grid_cell);
    fn grid_cells_look_equal(_: *const grid_cell, _: *const grid_cell) -> libc::c_int;
    fn screen_write_backspace(_: *mut screen_write_ctx);
    fn screen_write_alignmenttest(_: *mut screen_write_ctx);
    fn screen_write_cursormove(
        _: *mut screen_write_ctx,
        _: libc::c_int,
        _: libc::c_int,
        _: libc::c_int,
    );
    fn screen_write_mode_clear(_: *mut screen_write_ctx, _: libc::c_int);
    fn screen_write_mode_set(_: *mut screen_write_ctx, _: libc::c_int);
    fn screen_write_reverseindex(_: *mut screen_write_ctx, _: u_int);
    fn screen_write_fullredraw(_: *mut screen_write_ctx);
    fn screen_write_reset(_: *mut screen_write_ctx);
    static grid_default_cell: grid_cell;
    fn colour_palette_clear(_: *mut colour_palette);
    fn window_set_name(_: *mut window, _: *const libc::c_char);
    fn screen_set_title(_: *mut screen, _: *const libc::c_char) -> libc::c_int;
    fn grid_get_line(_: *mut grid, _: u_int) -> *mut grid_line;
    fn screen_set_cursor_colour(_: *mut screen, _: libc::c_int);
    fn colour_palette_set(_: *mut colour_palette, _: libc::c_int, _: libc::c_int) -> libc::c_int;
    fn screen_write_stop(_: *mut screen_write_ctx);
    fn screen_write_setselection(
        _: *mut screen_write_ctx,
        _: *const libc::c_char,
        _: *mut u_char,
        _: u_int,
    );
    fn screen_write_start_pane(_: *mut screen_write_ctx, _: *mut window_pane, _: *mut screen);
    fn colour_parseX11(_: *const libc::c_char) -> libc::c_int;
    fn colour_split_rgb(_: libc::c_int, _: *mut u_char, _: *mut u_char, _: *mut u_char);
    fn colour_force_rgb(_: libc::c_int) -> libc::c_int;
    fn screen_set_path(_: *mut screen, _: *const libc::c_char);
    fn colour_palette_get(_: *mut colour_palette, _: libc::c_int) -> libc::c_int;
    fn screen_set_cursor_style(_: u_int, _: *mut screen_cursor_style, _: *mut libc::c_int);
    fn screen_write_scrolldown(_: *mut screen_write_ctx, _: u_int, _: u_int);
    fn screen_write_scrollup(_: *mut screen_write_ctx, _: u_int, _: u_int);
    fn screen_write_alternateon(_: *mut screen_write_ctx, _: *mut grid_cell, _: libc::c_int);
    fn screen_write_clearscreen(_: *mut screen_write_ctx, _: u_int);
    fn tty_default_colours(_: *mut grid_cell, _: *mut window_pane);
    fn colour_join_rgb(_: u_char, _: u_char, _: u_char) -> libc::c_int;
    fn screen_write_alternateoff(_: *mut screen_write_ctx, _: *mut grid_cell, _: libc::c_int);
    fn screen_write_insertline(_: *mut screen_write_ctx, _: u_int, _: u_int);
    fn screen_write_insertcharacter(_: *mut screen_write_ctx, _: u_int, _: u_int);
    fn screen_write_clearline(_: *mut screen_write_ctx, _: u_int);
    fn screen_write_clearstartofline(_: *mut screen_write_ctx, _: u_int);
    fn screen_write_clearendofline(_: *mut screen_write_ctx, _: u_int);
    fn screen_write_clearhistory(_: *mut screen_write_ctx);
    fn screen_write_clearstartofscreen(_: *mut screen_write_ctx, _: u_int);
    fn screen_write_clearendofscreen(_: *mut screen_write_ctx, _: u_int);
    fn screen_write_deleteline(_: *mut screen_write_ctx, _: u_int, _: u_int);
    fn screen_write_scrollregion(_: *mut screen_write_ctx, _: u_int, _: u_int);
    fn screen_write_deletecharacter(_: *mut screen_write_ctx, _: u_int, _: u_int);
    fn screen_write_clearcharacter(_: *mut screen_write_ctx, _: u_int, _: u_int);
    fn screen_write_cursorup(_: *mut screen_write_ctx, _: u_int);
    fn screen_write_cursordown(_: *mut screen_write_ctx, _: u_int);
    fn screen_pop_title(_: *mut screen);
    fn screen_push_title(_: *mut screen);
    fn screen_write_cursorright(_: *mut screen_write_ctx, _: u_int);
    fn screen_write_cursorleft(_: *mut screen_write_ctx, _: u_int);
    fn screen_write_rawstring(_: *mut screen_write_ctx, _: *mut u_char, _: u_int, _: libc::c_int);
    fn screen_write_start(_: *mut screen_write_ctx, _: *mut screen);
    fn window_pane_update_used_data(_: *mut window_pane, _: *mut window_pane_offset, _: size_t);
    fn screen_write_collect_end(_: *mut screen_write_ctx);
    fn window_update_activity(_: *mut window);
    fn window_pane_get_new_data(
        _: *mut window_pane,
        _: *mut window_pane_offset,
        _: *mut size_t,
    ) -> *mut libc::c_void;
    fn screen_write_start_callback(
        _: *mut screen_write_ctx,
        _: *mut screen,
        _: screen_write_init_ctx_cb,
        _: *mut libc::c_void,
    );
    fn utf8_copy(_: *mut utf8_data, _: *const utf8_data);
    fn log_debug(_: *const libc::c_char, _: ...);
    fn utf8_append(_: *mut utf8_data, _: u_char) -> utf8_state;
    fn fatalx(_: *const libc::c_char, _: ...) -> !;
    fn session_has(_: *mut session, _: *mut window) -> libc::c_int;
    fn utf8_isvalid(_: *const libc::c_char) -> libc::c_int;
    fn utf8_set(_: *mut utf8_data, _: u_char);
    fn utf8_open(_: *mut utf8_data, _: u_char) -> utf8_state;
    fn hyperlinks_put(_: *mut hyperlinks, _: *const libc::c_char, _: *const libc::c_char) -> u_int;
}
pub type __builtin_va_list = [__va_list_tag; 1];
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __va_list_tag {
    pub gp_offset: libc::c_uint,
    pub fp_offset: libc::c_uint,
    pub overflow_arg_area: *mut libc::c_void,
    pub reg_save_area: *mut libc::c_void,
}
pub type __u_char = libc::c_uchar;
pub type __u_short = libc::c_ushort;
pub type __u_int = libc::c_uint;
pub type __uint8_t = libc::c_uchar;
pub type __uint64_t = libc::c_ulong;
pub type __pid_t = libc::c_int;
pub type __time_t = libc::c_long;
pub type __suseconds_t = libc::c_long;
pub type u_char = __u_char;
pub type u_short = __u_short;
pub type u_int = __u_int;
pub type pid_t = __pid_t;
pub type time_t = __time_t;
pub type size_t = libc::c_ulong;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct timeval {
    pub tv_sec: __time_t,
    pub tv_usec: __suseconds_t,
}
pub type uint8_t = __uint8_t;
pub type uint64_t = __uint64_t;
pub type va_list = __builtin_va_list;
pub type __compar_fn_t =
    Option<unsafe extern "C" fn(*const libc::c_void, *const libc::c_void) -> libc::c_int>;
pub type cc_t = libc::c_uchar;
pub type speed_t = libc::c_uint;
pub type tcflag_t = libc::c_uint;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct termios {
    pub c_iflag: tcflag_t,
    pub c_oflag: tcflag_t,
    pub c_cflag: tcflag_t,
    pub c_lflag: tcflag_t,
    pub c_line: cc_t,
    pub c_cc: [cc_t; 32],
    pub c_ispeed: speed_t,
    pub c_ospeed: speed_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event {
    pub ev_evcallback: event_callback,
    pub ev_timeout_pos: C2RustUnnamed_4,
    pub ev_fd: libc::c_int,
    pub ev_base: *mut event_base,
    pub ev_: C2RustUnnamed,
    pub ev_events: libc::c_short,
    pub ev_res: libc::c_short,
    pub ev_timeout: timeval,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed {
    pub ev_io: C2RustUnnamed_2,
    pub ev_signal: C2RustUnnamed_0,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_0 {
    pub ev_signal_next: C2RustUnnamed_1,
    pub ev_ncalls: libc::c_short,
    pub ev_pncalls: *mut libc::c_short,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_1 {
    pub le_next: *mut event,
    pub le_prev: *mut *mut event,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_2 {
    pub ev_io_next: C2RustUnnamed_3,
    pub ev_timeout: timeval,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_3 {
    pub le_next: *mut event,
    pub le_prev: *mut *mut event,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_4 {
    pub ev_next_with_common_timeout: C2RustUnnamed_5,
    pub min_heap_idx: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_5 {
    pub tqe_next: *mut event,
    pub tqe_prev: *mut *mut event,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event_callback {
    pub evcb_active_next: C2RustUnnamed_7,
    pub evcb_flags: libc::c_short,
    pub evcb_pri: uint8_t,
    pub evcb_closure: uint8_t,
    pub evcb_cb_union: C2RustUnnamed_6,
    pub evcb_arg: *mut libc::c_void,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_6 {
    pub evcb_callback:
        Option<unsafe extern "C" fn(libc::c_int, libc::c_short, *mut libc::c_void) -> ()>,
    pub evcb_selfcb: Option<unsafe extern "C" fn(*mut event_callback, *mut libc::c_void) -> ()>,
    pub evcb_evfinalize: Option<unsafe extern "C" fn(*mut event, *mut libc::c_void) -> ()>,
    pub evcb_cbfinalize: Option<unsafe extern "C" fn(*mut event_callback, *mut libc::c_void) -> ()>,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_7 {
    pub tqe_next: *mut event_callback,
    pub tqe_prev: *mut *mut event_callback,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct bufferevent {
    pub ev_base: *mut event_base,
    pub be_ops: *const bufferevent_ops,
    pub ev_read: event,
    pub ev_write: event,
    pub input: *mut evbuffer,
    pub output: *mut evbuffer,
    pub wm_read: event_watermark,
    pub wm_write: event_watermark,
    pub readcb: bufferevent_data_cb,
    pub writecb: bufferevent_data_cb,
    pub errorcb: bufferevent_event_cb,
    pub cbarg: *mut libc::c_void,
    pub timeout_read: timeval,
    pub timeout_write: timeval,
    pub enabled: libc::c_short,
}
pub type bufferevent_event_cb =
    Option<unsafe extern "C" fn(*mut bufferevent, libc::c_short, *mut libc::c_void) -> ()>;
pub type bufferevent_data_cb =
    Option<unsafe extern "C" fn(*mut bufferevent, *mut libc::c_void) -> ()>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event_watermark {
    pub low: size_t,
    pub high: size_t,
}
pub type bitstr_t = libc::c_uchar;
pub type msgtype = libc::c_uint;
pub const MSG_READ_CANCEL: msgtype = 307;
pub const MSG_WRITE_CLOSE: msgtype = 306;
pub const MSG_WRITE_READY: msgtype = 305;
pub const MSG_WRITE: msgtype = 304;
pub const MSG_WRITE_OPEN: msgtype = 303;
pub const MSG_READ_DONE: msgtype = 302;
pub const MSG_READ: msgtype = 301;
pub const MSG_READ_OPEN: msgtype = 300;
pub const MSG_FLAGS: msgtype = 218;
pub const MSG_EXEC: msgtype = 217;
pub const MSG_WAKEUP: msgtype = 216;
pub const MSG_UNLOCK: msgtype = 215;
pub const MSG_SUSPEND: msgtype = 214;
pub const MSG_OLDSTDOUT: msgtype = 213;
pub const MSG_OLDSTDIN: msgtype = 212;
pub const MSG_OLDSTDERR: msgtype = 211;
pub const MSG_SHUTDOWN: msgtype = 210;
pub const MSG_SHELL: msgtype = 209;
pub const MSG_RESIZE: msgtype = 208;
pub const MSG_READY: msgtype = 207;
pub const MSG_LOCK: msgtype = 206;
pub const MSG_EXITING: msgtype = 205;
pub const MSG_EXITED: msgtype = 204;
pub const MSG_EXIT: msgtype = 203;
pub const MSG_DETACHKILL: msgtype = 202;
pub const MSG_DETACH: msgtype = 201;
pub const MSG_COMMAND: msgtype = 200;
pub const MSG_IDENTIFY_TERMINFO: msgtype = 112;
pub const MSG_IDENTIFY_LONGFLAGS: msgtype = 111;
pub const MSG_IDENTIFY_STDOUT: msgtype = 110;
pub const MSG_IDENTIFY_FEATURES: msgtype = 109;
pub const MSG_IDENTIFY_CWD: msgtype = 108;
pub const MSG_IDENTIFY_CLIENTPID: msgtype = 107;
pub const MSG_IDENTIFY_DONE: msgtype = 106;
pub const MSG_IDENTIFY_ENVIRON: msgtype = 105;
pub const MSG_IDENTIFY_STDIN: msgtype = 104;
pub const MSG_IDENTIFY_OLDCWD: msgtype = 103;
pub const MSG_IDENTIFY_TTYNAME: msgtype = 102;
pub const MSG_IDENTIFY_TERM: msgtype = 101;
pub const MSG_IDENTIFY_FLAGS: msgtype = 100;
pub const MSG_VERSION: msgtype = 12;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client {
    pub name: *const libc::c_char,
    pub peer: *mut tmuxpeer,
    pub queue: *mut cmdq_list,
    pub windows: client_windows,
    pub control_state: *mut control_state,
    pub pause_age: u_int,
    pub pid: pid_t,
    pub fd: libc::c_int,
    pub out_fd: libc::c_int,
    pub event: event,
    pub retval: libc::c_int,
    pub creation_time: timeval,
    pub activity_time: timeval,
    pub last_activity_time: timeval,
    pub environ: *mut environ,
    pub jobs: *mut format_job_tree,
    pub title: *mut libc::c_char,
    pub path: *mut libc::c_char,
    pub cwd: *const libc::c_char,
    pub term_name: *mut libc::c_char,
    pub term_features: libc::c_int,
    pub term_type: *mut libc::c_char,
    pub term_caps: *mut *mut libc::c_char,
    pub term_ncaps: u_int,
    pub ttyname: *mut libc::c_char,
    pub tty: tty,
    pub written: size_t,
    pub discarded: size_t,
    pub redraw: size_t,
    pub repeat_timer: event,
    pub click_timer: event,
    pub click_button: u_int,
    pub click_event: mouse_event,
    pub status: status_line,
    pub flags: uint64_t,
    pub exit_type: C2RustUnnamed_33,
    pub exit_msgtype: msgtype,
    pub exit_session: *mut libc::c_char,
    pub exit_message: *mut libc::c_char,
    pub keytable: *mut key_table,
    pub last_key: key_code,
    pub redraw_panes: uint64_t,
    pub redraw_scrollbars: uint64_t,
    pub message_ignore_keys: libc::c_int,
    pub message_ignore_styles: libc::c_int,
    pub message_string: *mut libc::c_char,
    pub message_timer: event,
    pub prompt_string: *mut libc::c_char,
    pub prompt_buffer: *mut utf8_data,
    pub prompt_last: *mut libc::c_char,
    pub prompt_index: size_t,
    pub prompt_inputcb: prompt_input_cb,
    pub prompt_freecb: prompt_free_cb,
    pub prompt_data: *mut libc::c_void,
    pub prompt_hindex: [u_int; 4],
    pub prompt_mode: C2RustUnnamed_30,
    pub prompt_saved: *mut utf8_data,
    pub prompt_flags: libc::c_int,
    pub prompt_type: prompt_type,
    pub prompt_cursor: libc::c_int,
    pub session: *mut session,
    pub last_session: *mut session,
    pub references: libc::c_int,
    pub pan_window: *mut libc::c_void,
    pub pan_ox: u_int,
    pub pan_oy: u_int,
    pub overlay_check: overlay_check_cb,
    pub overlay_mode: overlay_mode_cb,
    pub overlay_draw: overlay_draw_cb,
    pub overlay_key: overlay_key_cb,
    pub overlay_free: overlay_free_cb,
    pub overlay_resize: overlay_resize_cb,
    pub overlay_data: *mut libc::c_void,
    pub overlay_timer: event,
    pub files: client_files,
    pub clipboard_panes: *mut u_int,
    pub clipboard_npanes: u_int,
    pub entry: C2RustUnnamed_8,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_8 {
    pub tqe_next: *mut client,
    pub tqe_prev: *mut *mut client,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_files {
    pub rbh_root: *mut client_file,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_file {
    pub c: *mut client,
    pub peer: *mut tmuxpeer,
    pub tree: *mut client_files,
    pub references: libc::c_int,
    pub stream: libc::c_int,
    pub path: *mut libc::c_char,
    pub buffer: *mut evbuffer,
    pub event: *mut bufferevent,
    pub fd: libc::c_int,
    pub error: libc::c_int,
    pub closed: libc::c_int,
    pub cb: client_file_cb,
    pub data: *mut libc::c_void,
    pub entry: C2RustUnnamed_9,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_9 {
    pub rbe_left: *mut client_file,
    pub rbe_right: *mut client_file,
    pub rbe_parent: *mut client_file,
    pub rbe_color: libc::c_int,
}
pub type client_file_cb = Option<
    unsafe extern "C" fn(
        *mut client,
        *const libc::c_char,
        libc::c_int,
        libc::c_int,
        *mut evbuffer,
        *mut libc::c_void,
    ) -> (),
>;
pub type overlay_resize_cb = Option<unsafe extern "C" fn(*mut client, *mut libc::c_void) -> ()>;
pub type overlay_free_cb = Option<unsafe extern "C" fn(*mut client, *mut libc::c_void) -> ()>;
pub type overlay_key_cb =
    Option<unsafe extern "C" fn(*mut client, *mut libc::c_void, *mut key_event) -> libc::c_int>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_event {
    pub key: key_code,
    pub m: mouse_event,
    pub buf: *mut libc::c_char,
    pub len: size_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct mouse_event {
    pub valid: libc::c_int,
    pub ignore: libc::c_int,
    pub key: key_code,
    pub statusat: libc::c_int,
    pub statuslines: u_int,
    pub x: u_int,
    pub y: u_int,
    pub b: u_int,
    pub lx: u_int,
    pub ly: u_int,
    pub lb: u_int,
    pub ox: u_int,
    pub oy: u_int,
    pub s: libc::c_int,
    pub w: libc::c_int,
    pub wp: libc::c_int,
    pub sgr_type: u_int,
    pub sgr_b: u_int,
}
pub type key_code = libc::c_ulonglong;
pub type overlay_draw_cb =
    Option<unsafe extern "C" fn(*mut client, *mut libc::c_void, *mut screen_redraw_ctx) -> ()>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct screen_redraw_ctx {
    pub c: *mut client,
    pub statuslines: u_int,
    pub statustop: libc::c_int,
    pub pane_status: libc::c_int,
    pub pane_lines: pane_lines,
    pub pane_scrollbars: libc::c_int,
    pub pane_scrollbars_pos: libc::c_int,
    pub no_pane_gc: grid_cell,
    pub no_pane_gc_set: libc::c_int,
    pub sx: u_int,
    pub sy: u_int,
    pub ox: u_int,
    pub oy: u_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct grid_cell {
    pub data: utf8_data,
    pub attr: u_short,
    pub flags: u_char,
    pub fg: libc::c_int,
    pub bg: libc::c_int,
    pub us: libc::c_int,
    pub link: u_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct utf8_data {
    pub data: [u_char; 21],
    pub have: u_char,
    pub size: u_char,
    pub width: u_char,
}
pub type pane_lines = libc::c_uint;
pub const PANE_LINES_NUMBER: pane_lines = 4;
pub const PANE_LINES_SIMPLE: pane_lines = 3;
pub const PANE_LINES_HEAVY: pane_lines = 2;
pub const PANE_LINES_DOUBLE: pane_lines = 1;
pub const PANE_LINES_SINGLE: pane_lines = 0;
pub type overlay_mode_cb = Option<
    unsafe extern "C" fn(*mut client, *mut libc::c_void, *mut u_int, *mut u_int) -> *mut screen,
>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct screen {
    pub title: *mut libc::c_char,
    pub path: *mut libc::c_char,
    pub titles: *mut screen_titles,
    pub grid: *mut grid,
    pub cx: u_int,
    pub cy: u_int,
    pub cstyle: screen_cursor_style,
    pub default_cstyle: screen_cursor_style,
    pub ccolour: libc::c_int,
    pub default_ccolour: libc::c_int,
    pub rupper: u_int,
    pub rlower: u_int,
    pub mode: libc::c_int,
    pub default_mode: libc::c_int,
    pub saved_cx: u_int,
    pub saved_cy: u_int,
    pub saved_grid: *mut grid,
    pub saved_cell: grid_cell,
    pub saved_flags: libc::c_int,
    pub tabs: *mut bitstr_t,
    pub sel: *mut screen_sel,
    pub write_list: *mut screen_write_cline,
    pub hyperlinks: *mut hyperlinks,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct grid {
    pub flags: libc::c_int,
    pub sx: u_int,
    pub sy: u_int,
    pub hscrolled: u_int,
    pub hsize: u_int,
    pub hlimit: u_int,
    pub linedata: *mut grid_line,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct grid_line {
    pub celldata: *mut grid_cell_entry,
    pub cellused: u_int,
    pub cellsize: u_int,
    pub extddata: *mut grid_extd_entry,
    pub extdsize: u_int,
    pub flags: libc::c_int,
    pub time: time_t,
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct grid_extd_entry {
    pub data: utf8_char,
    pub attr: u_short,
    pub flags: u_char,
    pub fg: libc::c_int,
    pub bg: libc::c_int,
    pub us: libc::c_int,
    pub link: u_int,
}
pub type utf8_char = u_int;
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct grid_cell_entry {
    pub c2rust_unnamed: C2RustUnnamed_10,
    pub flags: u_char,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_10 {
    pub offset: u_int,
    pub data: C2RustUnnamed_11,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_11 {
    pub attr: u_char,
    pub fg: u_char,
    pub bg: u_char,
    pub data: u_char,
}
pub type screen_cursor_style = libc::c_uint;
pub const SCREEN_CURSOR_BAR: screen_cursor_style = 3;
pub const SCREEN_CURSOR_UNDERLINE: screen_cursor_style = 2;
pub const SCREEN_CURSOR_BLOCK: screen_cursor_style = 1;
pub const SCREEN_CURSOR_DEFAULT: screen_cursor_style = 0;
pub type overlay_check_cb = Option<
    unsafe extern "C" fn(
        *mut client,
        *mut libc::c_void,
        u_int,
        u_int,
        u_int,
        *mut overlay_ranges,
    ) -> (),
>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct overlay_ranges {
    pub px: [u_int; 3],
    pub nx: [u_int; 3],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct session {
    pub id: u_int,
    pub name: *mut libc::c_char,
    pub cwd: *const libc::c_char,
    pub creation_time: timeval,
    pub last_attached_time: timeval,
    pub activity_time: timeval,
    pub last_activity_time: timeval,
    pub lock_timer: event,
    pub curw: *mut winlink,
    pub lastw: winlink_stack,
    pub windows: winlinks,
    pub statusat: libc::c_int,
    pub statuslines: u_int,
    pub options: *mut options,
    pub flags: libc::c_int,
    pub attached: u_int,
    pub tio: *mut termios,
    pub environ: *mut environ,
    pub references: libc::c_int,
    pub gentry: C2RustUnnamed_13,
    pub entry: C2RustUnnamed_12,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_12 {
    pub rbe_left: *mut session,
    pub rbe_right: *mut session,
    pub rbe_parent: *mut session,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_13 {
    pub tqe_next: *mut session,
    pub tqe_prev: *mut *mut session,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct winlinks {
    pub rbh_root: *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct winlink {
    pub idx: libc::c_int,
    pub session: *mut session,
    pub window: *mut window,
    pub flags: libc::c_int,
    pub entry: C2RustUnnamed_16,
    pub wentry: C2RustUnnamed_15,
    pub sentry: C2RustUnnamed_14,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_14 {
    pub tqe_next: *mut winlink,
    pub tqe_prev: *mut *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_15 {
    pub tqe_next: *mut winlink,
    pub tqe_prev: *mut *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_16 {
    pub rbe_left: *mut winlink,
    pub rbe_right: *mut winlink,
    pub rbe_parent: *mut winlink,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window {
    pub id: u_int,
    pub latest: *mut libc::c_void,
    pub name: *mut libc::c_char,
    pub name_event: event,
    pub name_time: timeval,
    pub alerts_timer: event,
    pub offset_timer: event,
    pub activity_time: timeval,
    pub active: *mut window_pane,
    pub last_panes: window_panes,
    pub panes: window_panes,
    pub lastlayout: libc::c_int,
    pub layout_root: *mut layout_cell,
    pub saved_layout_root: *mut layout_cell,
    pub old_layout: *mut libc::c_char,
    pub sx: u_int,
    pub sy: u_int,
    pub manual_sx: u_int,
    pub manual_sy: u_int,
    pub xpixel: u_int,
    pub ypixel: u_int,
    pub new_sx: u_int,
    pub new_sy: u_int,
    pub new_xpixel: u_int,
    pub new_ypixel: u_int,
    pub fill_character: *mut utf8_data,
    pub flags: libc::c_int,
    pub alerts_queued: libc::c_int,
    pub alerts_entry: C2RustUnnamed_19,
    pub options: *mut options,
    pub references: u_int,
    pub winlinks: C2RustUnnamed_18,
    pub entry: C2RustUnnamed_17,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_17 {
    pub rbe_left: *mut window,
    pub rbe_right: *mut window,
    pub rbe_parent: *mut window,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_18 {
    pub tqh_first: *mut winlink,
    pub tqh_last: *mut *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_19 {
    pub tqe_next: *mut window,
    pub tqe_prev: *mut *mut window,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct layout_cell {
    pub type_0: layout_type,
    pub parent: *mut layout_cell,
    pub sx: u_int,
    pub sy: u_int,
    pub xoff: u_int,
    pub yoff: u_int,
    pub wp: *mut window_pane,
    pub cells: layout_cells,
    pub entry: C2RustUnnamed_20,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_20 {
    pub tqe_next: *mut layout_cell,
    pub tqe_prev: *mut *mut layout_cell,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct layout_cells {
    pub tqh_first: *mut layout_cell,
    pub tqh_last: *mut *mut layout_cell,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane {
    pub id: u_int,
    pub active_point: u_int,
    pub window: *mut window,
    pub options: *mut options,
    pub layout_cell: *mut layout_cell,
    pub saved_layout_cell: *mut layout_cell,
    pub sx: u_int,
    pub sy: u_int,
    pub xoff: u_int,
    pub yoff: u_int,
    pub flags: libc::c_int,
    pub sb_slider_y: u_int,
    pub sb_slider_h: u_int,
    pub argc: libc::c_int,
    pub argv: *mut *mut libc::c_char,
    pub shell: *mut libc::c_char,
    pub cwd: *mut libc::c_char,
    pub pid: pid_t,
    pub tty: [libc::c_char; 32],
    pub status: libc::c_int,
    pub dead_time: timeval,
    pub fd: libc::c_int,
    pub event: *mut bufferevent,
    pub offset: window_pane_offset,
    pub base_offset: size_t,
    pub resize_queue: window_pane_resizes,
    pub resize_timer: event,
    pub ictx: *mut input_ctx,
    pub cached_gc: grid_cell,
    pub cached_active_gc: grid_cell,
    pub palette: colour_palette,
    pub pipe_fd: libc::c_int,
    pub pipe_event: *mut bufferevent,
    pub pipe_offset: window_pane_offset,
    pub screen: *mut screen,
    pub base: screen,
    pub status_screen: screen,
    pub status_size: size_t,
    pub modes: C2RustUnnamed_24,
    pub searchstr: *mut libc::c_char,
    pub searchregex: libc::c_int,
    pub border_gc_set: libc::c_int,
    pub border_gc: grid_cell,
    pub control_bg: libc::c_int,
    pub control_fg: libc::c_int,
    pub scrollbar_style: style,
    pub entry: C2RustUnnamed_23,
    pub sentry: C2RustUnnamed_22,
    pub tree_entry: C2RustUnnamed_21,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_21 {
    pub rbe_left: *mut window_pane,
    pub rbe_right: *mut window_pane,
    pub rbe_parent: *mut window_pane,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_22 {
    pub tqe_next: *mut window_pane,
    pub tqe_prev: *mut *mut window_pane,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_23 {
    pub tqe_next: *mut window_pane,
    pub tqe_prev: *mut *mut window_pane,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct style {
    pub gc: grid_cell,
    pub ignore: libc::c_int,
    pub fill: libc::c_int,
    pub align: style_align,
    pub list: style_list,
    pub range_type: style_range_type,
    pub range_argument: u_int,
    pub range_string: [libc::c_char; 16],
    pub width: libc::c_int,
    pub pad: libc::c_int,
    pub default_type: style_default_type,
}
pub type style_default_type = libc::c_uint;
pub const STYLE_DEFAULT_POP: style_default_type = 2;
pub const STYLE_DEFAULT_PUSH: style_default_type = 1;
pub const STYLE_DEFAULT_BASE: style_default_type = 0;
pub type style_range_type = libc::c_uint;
pub const STYLE_RANGE_USER: style_range_type = 6;
pub const STYLE_RANGE_SESSION: style_range_type = 5;
pub const STYLE_RANGE_WINDOW: style_range_type = 4;
pub const STYLE_RANGE_PANE: style_range_type = 3;
pub const STYLE_RANGE_RIGHT: style_range_type = 2;
pub const STYLE_RANGE_LEFT: style_range_type = 1;
pub const STYLE_RANGE_NONE: style_range_type = 0;
pub type style_list = libc::c_uint;
pub const STYLE_LIST_RIGHT_MARKER: style_list = 4;
pub const STYLE_LIST_LEFT_MARKER: style_list = 3;
pub const STYLE_LIST_FOCUS: style_list = 2;
pub const STYLE_LIST_ON: style_list = 1;
pub const STYLE_LIST_OFF: style_list = 0;
pub type style_align = libc::c_uint;
pub const STYLE_ALIGN_ABSOLUTE_CENTRE: style_align = 4;
pub const STYLE_ALIGN_RIGHT: style_align = 3;
pub const STYLE_ALIGN_CENTRE: style_align = 2;
pub const STYLE_ALIGN_LEFT: style_align = 1;
pub const STYLE_ALIGN_DEFAULT: style_align = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_24 {
    pub tqh_first: *mut window_mode_entry,
    pub tqh_last: *mut *mut window_mode_entry,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_mode_entry {
    pub wp: *mut window_pane,
    pub swp: *mut window_pane,
    pub mode: *const window_mode,
    pub data: *mut libc::c_void,
    pub screen: *mut screen,
    pub prefix: u_int,
    pub entry: C2RustUnnamed_25,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_25 {
    pub tqe_next: *mut window_mode_entry,
    pub tqe_prev: *mut *mut window_mode_entry,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_mode {
    pub name: *const libc::c_char,
    pub default_format: *const libc::c_char,
    pub init: Option<
        unsafe extern "C" fn(*mut window_mode_entry, *mut cmd_find_state, *mut args) -> *mut screen,
    >,
    pub free: Option<unsafe extern "C" fn(*mut window_mode_entry) -> ()>,
    pub resize: Option<unsafe extern "C" fn(*mut window_mode_entry, u_int, u_int) -> ()>,
    pub update: Option<unsafe extern "C" fn(*mut window_mode_entry) -> ()>,
    pub key: Option<
        unsafe extern "C" fn(
            *mut window_mode_entry,
            *mut client,
            *mut session,
            *mut winlink,
            key_code,
            *mut mouse_event,
        ) -> (),
    >,
    pub key_table: Option<unsafe extern "C" fn(*mut window_mode_entry) -> *const libc::c_char>,
    pub command: Option<
        unsafe extern "C" fn(
            *mut window_mode_entry,
            *mut client,
            *mut session,
            *mut winlink,
            *mut args,
            *mut mouse_event,
        ) -> (),
    >,
    pub formats: Option<unsafe extern "C" fn(*mut window_mode_entry, *mut format_tree) -> ()>,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cmd_find_state {
    pub flags: libc::c_int,
    pub current: *mut cmd_find_state,
    pub s: *mut session,
    pub wl: *mut winlink,
    pub w: *mut window,
    pub wp: *mut window_pane,
    pub idx: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane_offset {
    pub used: size_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct colour_palette {
    pub fg: libc::c_int,
    pub bg: libc::c_int,
    pub palette: *mut libc::c_int,
    pub default_palette: *mut libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct input_ctx {
    pub wp: *mut window_pane,
    pub event: *mut bufferevent,
    pub ctx: screen_write_ctx,
    pub palette: *mut colour_palette,
    pub cell: input_cell,
    pub old_cell: input_cell,
    pub old_cx: u_int,
    pub old_cy: u_int,
    pub old_mode: libc::c_int,
    pub interm_buf: [u_char; 4],
    pub interm_len: size_t,
    pub param_buf: [u_char; 64],
    pub param_len: size_t,
    pub input_buf: *mut u_char,
    pub input_len: size_t,
    pub input_space: size_t,
    pub input_end: C2RustUnnamed_28,
    pub param_list: [input_param; 24],
    pub param_list_len: u_int,
    pub utf8data: utf8_data,
    pub utf8started: libc::c_int,
    pub ch: libc::c_int,
    pub last: utf8_data,
    pub flags: libc::c_int,
    pub state: *const input_state,
    pub timer: event,
    pub since_ground: *mut evbuffer,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct input_state {
    pub name: *const libc::c_char,
    pub enter: Option<unsafe extern "C" fn(*mut input_ctx) -> ()>,
    pub exit: Option<unsafe extern "C" fn(*mut input_ctx) -> ()>,
    pub transitions: *const input_transition,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct input_transition {
    pub first: libc::c_int,
    pub last: libc::c_int,
    pub handler: Option<unsafe extern "C" fn(*mut input_ctx) -> libc::c_int>,
    pub state: *const input_state,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct input_param {
    pub type_0: C2RustUnnamed_27,
    pub c2rust_unnamed: C2RustUnnamed_26,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_26 {
    pub num: libc::c_int,
    pub str_0: *mut libc::c_char,
}
pub type C2RustUnnamed_27 = libc::c_uint;
pub const INPUT_STRING: C2RustUnnamed_27 = 2;
pub const INPUT_NUMBER: C2RustUnnamed_27 = 1;
pub const INPUT_MISSING: C2RustUnnamed_27 = 0;
pub type C2RustUnnamed_28 = libc::c_uint;
pub const INPUT_END_BEL: C2RustUnnamed_28 = 1;
pub const INPUT_END_ST: C2RustUnnamed_28 = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct input_cell {
    pub cell: grid_cell,
    pub set: libc::c_int,
    pub g0set: libc::c_int,
    pub g1set: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct screen_write_ctx {
    pub wp: *mut window_pane,
    pub s: *mut screen,
    pub flags: libc::c_int,
    pub init_ctx_cb: screen_write_init_ctx_cb,
    pub arg: *mut libc::c_void,
    pub item: *mut screen_write_citem,
    pub scrolled: u_int,
    pub bg: u_int,
}
pub type screen_write_init_ctx_cb =
    Option<unsafe extern "C" fn(*mut screen_write_ctx, *mut tty_ctx) -> ()>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct tty_ctx {
    pub s: *mut screen,
    pub redraw_cb: tty_ctx_redraw_cb,
    pub set_client_cb: tty_ctx_set_client_cb,
    pub arg: *mut libc::c_void,
    pub cell: *const grid_cell,
    pub wrapped: libc::c_int,
    pub num: u_int,
    pub ptr: *mut libc::c_void,
    pub ptr2: *mut libc::c_void,
    pub allow_invisible_panes: libc::c_int,
    pub ocx: u_int,
    pub ocy: u_int,
    pub orupper: u_int,
    pub orlower: u_int,
    pub xoff: u_int,
    pub yoff: u_int,
    pub rxoff: u_int,
    pub ryoff: u_int,
    pub sx: u_int,
    pub sy: u_int,
    pub bg: u_int,
    pub defaults: grid_cell,
    pub palette: *mut colour_palette,
    pub bigger: libc::c_int,
    pub wox: u_int,
    pub woy: u_int,
    pub wsx: u_int,
    pub wsy: u_int,
}
pub type tty_ctx_set_client_cb =
    Option<unsafe extern "C" fn(*mut tty_ctx, *mut client) -> libc::c_int>;
pub type tty_ctx_redraw_cb = Option<unsafe extern "C" fn(*const tty_ctx) -> ()>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane_resizes {
    pub tqh_first: *mut window_pane_resize,
    pub tqh_last: *mut *mut window_pane_resize,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane_resize {
    pub sx: u_int,
    pub sy: u_int,
    pub osx: u_int,
    pub osy: u_int,
    pub entry: C2RustUnnamed_29,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_29 {
    pub tqe_next: *mut window_pane_resize,
    pub tqe_prev: *mut *mut window_pane_resize,
}
pub type layout_type = libc::c_uint;
pub const LAYOUT_WINDOWPANE: layout_type = 2;
pub const LAYOUT_TOPBOTTOM: layout_type = 1;
pub const LAYOUT_LEFTRIGHT: layout_type = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_panes {
    pub tqh_first: *mut window_pane,
    pub tqh_last: *mut *mut window_pane,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct winlink_stack {
    pub tqh_first: *mut winlink,
    pub tqh_last: *mut *mut winlink,
}
pub type prompt_type = libc::c_uint;
pub const PROMPT_TYPE_INVALID: prompt_type = 255;
pub const PROMPT_TYPE_WINDOW_TARGET: prompt_type = 3;
pub const PROMPT_TYPE_TARGET: prompt_type = 2;
pub const PROMPT_TYPE_SEARCH: prompt_type = 1;
pub const PROMPT_TYPE_COMMAND: prompt_type = 0;
pub type C2RustUnnamed_30 = libc::c_uint;
pub const PROMPT_COMMAND: C2RustUnnamed_30 = 1;
pub const PROMPT_ENTRY: C2RustUnnamed_30 = 0;
pub type prompt_free_cb = Option<unsafe extern "C" fn(*mut libc::c_void) -> ()>;
pub type prompt_input_cb = Option<
    unsafe extern "C" fn(
        *mut client,
        *mut libc::c_void,
        *const libc::c_char,
        libc::c_int,
    ) -> libc::c_int,
>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_table {
    pub name: *const libc::c_char,
    pub activity_time: timeval,
    pub key_bindings: key_bindings,
    pub default_key_bindings: key_bindings,
    pub references: u_int,
    pub entry: C2RustUnnamed_31,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_31 {
    pub rbe_left: *mut key_table,
    pub rbe_right: *mut key_table,
    pub rbe_parent: *mut key_table,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_bindings {
    pub rbh_root: *mut key_binding,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_binding {
    pub key: key_code,
    pub cmdlist: *mut cmd_list,
    pub note: *const libc::c_char,
    pub flags: libc::c_int,
    pub entry: C2RustUnnamed_32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_32 {
    pub rbe_left: *mut key_binding,
    pub rbe_right: *mut key_binding,
    pub rbe_parent: *mut key_binding,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cmd_list {
    pub references: libc::c_int,
    pub group: u_int,
    pub list: *mut cmds,
}
pub type C2RustUnnamed_33 = libc::c_uint;
pub const CLIENT_EXIT_DETACH: C2RustUnnamed_33 = 2;
pub const CLIENT_EXIT_SHUTDOWN: C2RustUnnamed_33 = 1;
pub const CLIENT_EXIT_RETURN: C2RustUnnamed_33 = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct status_line {
    pub timer: event,
    pub screen: screen,
    pub active: *mut screen,
    pub references: libc::c_int,
    pub style: grid_cell,
    pub entries: [status_line_entry; 5],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct status_line_entry {
    pub expanded: *mut libc::c_char,
    pub ranges: style_ranges,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct style_ranges {
    pub tqh_first: *mut style_range,
    pub tqh_last: *mut *mut style_range,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct style_range {
    pub type_0: style_range_type,
    pub argument: u_int,
    pub string: [libc::c_char; 16],
    pub start: u_int,
    pub end: u_int,
    pub entry: C2RustUnnamed_34,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_34 {
    pub tqe_next: *mut style_range,
    pub tqe_prev: *mut *mut style_range,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct tty {
    pub client: *mut client,
    pub start_timer: event,
    pub clipboard_timer: event,
    pub last_requests: time_t,
    pub sx: u_int,
    pub sy: u_int,
    pub xpixel: u_int,
    pub ypixel: u_int,
    pub cx: u_int,
    pub cy: u_int,
    pub cstyle: screen_cursor_style,
    pub ccolour: libc::c_int,
    pub oflag: libc::c_int,
    pub oox: u_int,
    pub ooy: u_int,
    pub osx: u_int,
    pub osy: u_int,
    pub mode: libc::c_int,
    pub fg: libc::c_int,
    pub bg: libc::c_int,
    pub rlower: u_int,
    pub rupper: u_int,
    pub rleft: u_int,
    pub rright: u_int,
    pub event_in: event,
    pub in_0: *mut evbuffer,
    pub event_out: event,
    pub out: *mut evbuffer,
    pub timer: event,
    pub discarded: size_t,
    pub tio: termios,
    pub cell: grid_cell,
    pub last_cell: grid_cell,
    pub flags: libc::c_int,
    pub term: *mut tty_term,
    pub mouse_last_x: u_int,
    pub mouse_last_y: u_int,
    pub mouse_last_b: u_int,
    pub mouse_drag_flag: libc::c_int,
    pub mouse_scrolling_flag: libc::c_int,
    pub mouse_slider_mpos: libc::c_int,
    pub mouse_drag_update: Option<unsafe extern "C" fn(*mut client, *mut mouse_event) -> ()>,
    pub mouse_drag_release: Option<unsafe extern "C" fn(*mut client, *mut mouse_event) -> ()>,
    pub key_timer: event,
    pub key_tree: *mut tty_key,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct tty_term {
    pub name: *mut libc::c_char,
    pub tty: *mut tty,
    pub features: libc::c_int,
    pub acs: [[libc::c_char; 2]; 256],
    pub codes: *mut tty_code,
    pub flags: libc::c_int,
    pub entry: C2RustUnnamed_35,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_35 {
    pub le_next: *mut tty_term,
    pub le_prev: *mut *mut tty_term,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_windows {
    pub rbh_root: *mut client_window,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_window {
    pub window: u_int,
    pub pane: *mut window_pane,
    pub sx: u_int,
    pub sy: u_int,
    pub entry: C2RustUnnamed_36,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_36 {
    pub rbe_left: *mut client_window,
    pub rbe_right: *mut client_window,
    pub rbe_parent: *mut client_window,
    pub rbe_color: libc::c_int,
}
pub type utf8_state = libc::c_uint;
pub const UTF8_ERROR: utf8_state = 2;
pub const UTF8_DONE: utf8_state = 1;
pub const UTF8_MORE: utf8_state = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct clients {
    pub tqh_first: *mut client,
    pub tqh_last: *mut *mut client,
}
pub const INPUT_ESC_ST: input_esc_type = 14;
pub const INPUT_ESC_SCSG1_OFF: input_esc_type = 12;
pub const INPUT_ESC_SCSG1_ON: input_esc_type = 13;
pub const INPUT_ESC_SCSG0_OFF: input_esc_type = 10;
pub const INPUT_ESC_SCSG0_ON: input_esc_type = 11;
pub const INPUT_ESC_DECALN: input_esc_type = 0;
pub const INPUT_ESC_DECRC: input_esc_type = 3;
pub const INPUT_ESC_DECSC: input_esc_type = 4;
pub const INPUT_ESC_DECKPNM: input_esc_type = 2;
pub const INPUT_ESC_DECKPAM: input_esc_type = 1;
pub const INPUT_ESC_RI: input_esc_type = 8;
pub const INPUT_ESC_HTS: input_esc_type = 5;
pub const INPUT_ESC_NEL: input_esc_type = 7;
pub const INPUT_ESC_IND: input_esc_type = 6;
pub const INPUT_ESC_RIS: input_esc_type = 9;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct input_table_entry {
    pub ch: libc::c_int,
    pub interm: *const libc::c_char,
    pub type_0: libc::c_int,
}
pub const INPUT_CSI_XDA: input_csi_type = 37;
pub const INPUT_CSI_DECSCUSR: input_csi_type = 11;
pub const INPUT_CSI_VPA: input_csi_type = 35;
pub const INPUT_CSI_TBC: input_csi_type = 34;
pub const INPUT_CSI_SD: input_csi_type = 28;
pub const INPUT_CSI_SU: input_csi_type = 33;
pub const INPUT_CSI_SM_GRAPHICS: input_csi_type = 32;
pub const INPUT_CSI_SM_PRIVATE: input_csi_type = 31;
pub const INPUT_CSI_SM: input_csi_type = 30;
pub const INPUT_CSI_SGR: input_csi_type = 29;
pub const INPUT_CSI_SCP: input_csi_type = 27;
pub const INPUT_CSI_RM_PRIVATE: input_csi_type = 26;
pub const INPUT_CSI_RM: input_csi_type = 25;
pub const INPUT_CSI_RCP: input_csi_type = 23;
pub const INPUT_CSI_REP: input_csi_type = 24;
pub const INPUT_CSI_IL: input_csi_type = 20;
pub const INPUT_CSI_ICH: input_csi_type = 19;
pub const INPUT_CSI_HPA: input_csi_type = 18;
pub const INPUT_CSI_EL: input_csi_type = 17;
pub const INPUT_CSI_ED: input_csi_type = 16;
pub const INPUT_CSI_DSR: input_csi_type = 14;
pub const INPUT_CSI_DL: input_csi_type = 13;
pub const INPUT_CSI_DECSTBM: input_csi_type = 12;
pub const INPUT_CSI_DCH: input_csi_type = 10;
pub const INPUT_CSI_ECH: input_csi_type = 15;
pub const INPUT_CSI_DA_TWO: input_csi_type = 9;
pub const INPUT_CSI_DA: input_csi_type = 8;
pub const INPUT_CSI_CPL: input_csi_type = 2;
pub const INPUT_CSI_CNL: input_csi_type = 1;
pub const INPUT_CSI_CUU: input_csi_type = 7;
pub const INPUT_CSI_WINOPS: input_csi_type = 36;
pub const INPUT_CSI_MODOFF: input_csi_type = 21;
pub const INPUT_CSI_MODSET: input_csi_type = 22;
pub const INPUT_CSI_CUP: input_csi_type = 6;
pub const INPUT_CSI_CUF: input_csi_type = 5;
pub const INPUT_CSI_CUD: input_csi_type = 4;
pub const INPUT_CSI_CUB: input_csi_type = 3;
pub const INPUT_CSI_CBT: input_csi_type = 0;
pub type input_esc_type = libc::c_uint;
pub type input_csi_type = libc::c_uint;
static mut input_esc_table: [input_table_entry; 15] = [
    {
        let mut init = input_table_entry {
            ch: '0' as i32,
            interm: b"(\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_SCSG0_ON as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: '0' as i32,
            interm: b")\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_SCSG1_ON as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: '7' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_DECSC as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: '8' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_DECRC as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: '8' as i32,
            interm: b"#\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_DECALN as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: '=' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_DECKPAM as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: '>' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_DECKPNM as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'B' as i32,
            interm: b"(\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_SCSG0_OFF as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'B' as i32,
            interm: b")\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_SCSG1_OFF as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'D' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_IND as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'E' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_NEL as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'H' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_HTS as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'M' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_RI as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: '\\' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_ST as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'c' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_ESC_RIS as libc::c_int,
        };
        init
    },
];
static mut input_csi_table: [input_table_entry; 40] = [
    {
        let mut init = input_table_entry {
            ch: '@' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_ICH as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'A' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_CUU as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'B' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_CUD as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'C' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_CUF as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'D' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_CUB as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'E' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_CNL as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'F' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_CPL as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'G' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_HPA as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'H' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_CUP as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'J' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_ED as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'K' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_EL as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'L' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_IL as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'M' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_DL as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'P' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_DCH as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'S' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_SU as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'S' as i32,
            interm: b"?\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_SM_GRAPHICS as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'T' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_SD as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'X' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_ECH as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'Z' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_CBT as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: '`' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_HPA as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'b' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_REP as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'c' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_DA as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'c' as i32,
            interm: b">\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_DA_TWO as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'd' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_VPA as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'f' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_CUP as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'g' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_TBC as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'h' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_SM as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'h' as i32,
            interm: b"?\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_SM_PRIVATE as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'l' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_RM as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'l' as i32,
            interm: b"?\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_RM_PRIVATE as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'm' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_SGR as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'm' as i32,
            interm: b">\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_MODSET as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'n' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_DSR as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'n' as i32,
            interm: b">\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_MODOFF as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'q' as i32,
            interm: b" \0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_DECSCUSR as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'q' as i32,
            interm: b">\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_XDA as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'r' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_DECSTBM as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 's' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_SCP as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 't' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_WINOPS as libc::c_int,
        };
        init
    },
    {
        let mut init = input_table_entry {
            ch: 'u' as i32,
            interm: b"\0" as *const u8 as *const libc::c_char,
            type_0: INPUT_CSI_RCP as libc::c_int,
        };
        init
    },
];
static mut input_state_ground: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"ground\0" as *const u8 as *const libc::c_char,
            enter: Some(input_ground as unsafe extern "C" fn(*mut input_ctx) -> ()),
            exit: None,
            transitions: input_state_ground_table.as_ptr(),
        };
        init
    }
};
static mut input_state_esc_enter: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"esc_enter\0" as *const u8 as *const libc::c_char,
            enter: Some(input_clear as unsafe extern "C" fn(*mut input_ctx) -> ()),
            exit: None,
            transitions: input_state_esc_enter_table.as_ptr(),
        };
        init
    }
};
static mut input_state_esc_intermediate: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"esc_intermediate\0" as *const u8 as *const libc::c_char,
            enter: None,
            exit: None,
            transitions: input_state_esc_intermediate_table.as_ptr(),
        };
        init
    }
};
static mut input_state_csi_enter: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"csi_enter\0" as *const u8 as *const libc::c_char,
            enter: Some(input_clear as unsafe extern "C" fn(*mut input_ctx) -> ()),
            exit: None,
            transitions: input_state_csi_enter_table.as_ptr(),
        };
        init
    }
};
static mut input_state_csi_parameter: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"csi_parameter\0" as *const u8 as *const libc::c_char,
            enter: None,
            exit: None,
            transitions: input_state_csi_parameter_table.as_ptr(),
        };
        init
    }
};
static mut input_state_csi_intermediate: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"csi_intermediate\0" as *const u8 as *const libc::c_char,
            enter: None,
            exit: None,
            transitions: input_state_csi_intermediate_table.as_ptr(),
        };
        init
    }
};
static mut input_state_csi_ignore: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"csi_ignore\0" as *const u8 as *const libc::c_char,
            enter: None,
            exit: None,
            transitions: input_state_csi_ignore_table.as_ptr(),
        };
        init
    }
};
static mut input_state_dcs_enter: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"dcs_enter\0" as *const u8 as *const libc::c_char,
            enter: Some(input_enter_dcs as unsafe extern "C" fn(*mut input_ctx) -> ()),
            exit: None,
            transitions: input_state_dcs_enter_table.as_ptr(),
        };
        init
    }
};
static mut input_state_dcs_parameter: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"dcs_parameter\0" as *const u8 as *const libc::c_char,
            enter: None,
            exit: None,
            transitions: input_state_dcs_parameter_table.as_ptr(),
        };
        init
    }
};
static mut input_state_dcs_intermediate: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"dcs_intermediate\0" as *const u8 as *const libc::c_char,
            enter: None,
            exit: None,
            transitions: input_state_dcs_intermediate_table.as_ptr(),
        };
        init
    }
};
static mut input_state_dcs_handler: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"dcs_handler\0" as *const u8 as *const libc::c_char,
            enter: None,
            exit: None,
            transitions: input_state_dcs_handler_table.as_ptr(),
        };
        init
    }
};
static mut input_state_dcs_escape: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"dcs_escape\0" as *const u8 as *const libc::c_char,
            enter: None,
            exit: None,
            transitions: input_state_dcs_escape_table.as_ptr(),
        };
        init
    }
};
static mut input_state_dcs_ignore: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"dcs_ignore\0" as *const u8 as *const libc::c_char,
            enter: None,
            exit: None,
            transitions: input_state_dcs_ignore_table.as_ptr(),
        };
        init
    }
};
static mut input_state_osc_string: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"osc_string\0" as *const u8 as *const libc::c_char,
            enter: Some(input_enter_osc as unsafe extern "C" fn(*mut input_ctx) -> ()),
            exit: Some(input_exit_osc as unsafe extern "C" fn(*mut input_ctx) -> ()),
            transitions: input_state_osc_string_table.as_ptr(),
        };
        init
    }
};
static mut input_state_apc_string: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"apc_string\0" as *const u8 as *const libc::c_char,
            enter: Some(input_enter_apc as unsafe extern "C" fn(*mut input_ctx) -> ()),
            exit: Some(input_exit_apc as unsafe extern "C" fn(*mut input_ctx) -> ()),
            transitions: input_state_apc_string_table.as_ptr(),
        };
        init
    }
};
static mut input_state_rename_string: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"rename_string\0" as *const u8 as *const libc::c_char,
            enter: Some(input_enter_rename as unsafe extern "C" fn(*mut input_ctx) -> ()),
            exit: Some(input_exit_rename as unsafe extern "C" fn(*mut input_ctx) -> ()),
            transitions: input_state_rename_string_table.as_ptr(),
        };
        init
    }
};
static mut input_state_consume_st: input_state = unsafe {
    {
        let mut init = input_state {
            name: b"consume_st\0" as *const u8 as *const libc::c_char,
            enter: Some(input_enter_rename as unsafe extern "C" fn(*mut input_ctx) -> ()),
            exit: None,
            transitions: input_state_consume_st_table.as_ptr(),
        };
        init
    }
};
static mut input_state_ground_table: [input_transition; 10] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0x7e as libc::c_int,
                handler: Some(input_print as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x7f as libc::c_int,
                last: 0x7f as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x80 as libc::c_int,
                last: 0xff as libc::c_int,
                handler: Some(
                    input_top_bit_set as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_esc_enter_table: [input_transition; 23] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0x2f as libc::c_int,
                handler: Some(
                    input_intermediate as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_esc_intermediate as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x30 as libc::c_int,
                last: 0x4f as libc::c_int,
                handler: Some(
                    input_esc_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x50 as libc::c_int,
                last: 0x50 as libc::c_int,
                handler: None,
                state: &input_state_dcs_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x51 as libc::c_int,
                last: 0x57 as libc::c_int,
                handler: Some(
                    input_esc_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x58 as libc::c_int,
                last: 0x58 as libc::c_int,
                handler: None,
                state: &input_state_consume_st as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x59 as libc::c_int,
                last: 0x59 as libc::c_int,
                handler: Some(
                    input_esc_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x5a as libc::c_int,
                last: 0x5a as libc::c_int,
                handler: Some(
                    input_esc_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x5b as libc::c_int,
                last: 0x5b as libc::c_int,
                handler: None,
                state: &input_state_csi_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x5c as libc::c_int,
                last: 0x5c as libc::c_int,
                handler: Some(
                    input_esc_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x5d as libc::c_int,
                last: 0x5d as libc::c_int,
                handler: None,
                state: &input_state_osc_string as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x5e as libc::c_int,
                last: 0x5e as libc::c_int,
                handler: None,
                state: &input_state_consume_st as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x5f as libc::c_int,
                last: 0x5f as libc::c_int,
                handler: None,
                state: &input_state_apc_string as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x60 as libc::c_int,
                last: 0x6a as libc::c_int,
                handler: Some(
                    input_esc_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x6b as libc::c_int,
                last: 0x6b as libc::c_int,
                handler: None,
                state: &input_state_rename_string as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x6c as libc::c_int,
                last: 0x7e as libc::c_int,
                handler: Some(
                    input_esc_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x7f as libc::c_int,
                last: 0xff as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_esc_intermediate_table: [input_transition; 10] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0x2f as libc::c_int,
                handler: Some(
                    input_intermediate as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x30 as libc::c_int,
                last: 0x7e as libc::c_int,
                handler: Some(
                    input_esc_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x7f as libc::c_int,
                last: 0xff as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_csi_enter_table: [input_transition; 14] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0x2f as libc::c_int,
                handler: Some(
                    input_intermediate as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_csi_intermediate as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x30 as libc::c_int,
                last: 0x39 as libc::c_int,
                handler: Some(
                    input_parameter as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_csi_parameter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x3a as libc::c_int,
                last: 0x3a as libc::c_int,
                handler: Some(
                    input_parameter as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_csi_parameter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x3b as libc::c_int,
                last: 0x3b as libc::c_int,
                handler: Some(
                    input_parameter as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_csi_parameter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x3c as libc::c_int,
                last: 0x3f as libc::c_int,
                handler: Some(
                    input_intermediate as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_csi_parameter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x40 as libc::c_int,
                last: 0x7e as libc::c_int,
                handler: Some(
                    input_csi_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x7f as libc::c_int,
                last: 0xff as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_csi_parameter_table: [input_transition; 14] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0x2f as libc::c_int,
                handler: Some(
                    input_intermediate as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_csi_intermediate as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x30 as libc::c_int,
                last: 0x39 as libc::c_int,
                handler: Some(
                    input_parameter as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x3a as libc::c_int,
                last: 0x3a as libc::c_int,
                handler: Some(
                    input_parameter as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x3b as libc::c_int,
                last: 0x3b as libc::c_int,
                handler: Some(
                    input_parameter as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x3c as libc::c_int,
                last: 0x3f as libc::c_int,
                handler: None,
                state: &input_state_csi_ignore as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x40 as libc::c_int,
                last: 0x7e as libc::c_int,
                handler: Some(
                    input_csi_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x7f as libc::c_int,
                last: 0xff as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_csi_intermediate_table: [input_transition; 11] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0x2f as libc::c_int,
                handler: Some(
                    input_intermediate as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x30 as libc::c_int,
                last: 0x3f as libc::c_int,
                handler: None,
                state: &input_state_csi_ignore as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x40 as libc::c_int,
                last: 0x7e as libc::c_int,
                handler: Some(
                    input_csi_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x7f as libc::c_int,
                last: 0xff as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_csi_ignore_table: [input_transition; 10] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0x3f as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x40 as libc::c_int,
                last: 0x7e as libc::c_int,
                handler: None,
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x7f as libc::c_int,
                last: 0xff as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_dcs_enter_table: [input_transition; 14] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0x2f as libc::c_int,
                handler: Some(
                    input_intermediate as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_dcs_intermediate as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x30 as libc::c_int,
                last: 0x39 as libc::c_int,
                handler: Some(
                    input_parameter as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_dcs_parameter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x3a as libc::c_int,
                last: 0x3a as libc::c_int,
                handler: None,
                state: &input_state_dcs_ignore as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x3b as libc::c_int,
                last: 0x3b as libc::c_int,
                handler: Some(
                    input_parameter as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_dcs_parameter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x3c as libc::c_int,
                last: 0x3f as libc::c_int,
                handler: Some(
                    input_intermediate as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_dcs_parameter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x40 as libc::c_int,
                last: 0x7e as libc::c_int,
                handler: Some(input_input as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int),
                state: &input_state_dcs_handler as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x7f as libc::c_int,
                last: 0xff as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_dcs_parameter_table: [input_transition; 14] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0x2f as libc::c_int,
                handler: Some(
                    input_intermediate as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_dcs_intermediate as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x30 as libc::c_int,
                last: 0x39 as libc::c_int,
                handler: Some(
                    input_parameter as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x3a as libc::c_int,
                last: 0x3a as libc::c_int,
                handler: None,
                state: &input_state_dcs_ignore as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x3b as libc::c_int,
                last: 0x3b as libc::c_int,
                handler: Some(
                    input_parameter as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x3c as libc::c_int,
                last: 0x3f as libc::c_int,
                handler: None,
                state: &input_state_dcs_ignore as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x40 as libc::c_int,
                last: 0x7e as libc::c_int,
                handler: Some(input_input as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int),
                state: &input_state_dcs_handler as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x7f as libc::c_int,
                last: 0xff as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_dcs_intermediate_table: [input_transition; 11] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0x2f as libc::c_int,
                handler: Some(
                    input_intermediate as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x30 as libc::c_int,
                last: 0x3f as libc::c_int,
                handler: None,
                state: &input_state_dcs_ignore as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x40 as libc::c_int,
                last: 0x7e as libc::c_int,
                handler: Some(input_input as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int),
                state: &input_state_dcs_handler as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x7f as libc::c_int,
                last: 0xff as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_dcs_handler_table: [input_transition; 4] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(input_input as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_dcs_escape as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0xff as libc::c_int,
                handler: Some(input_input as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_dcs_escape_table: [input_transition; 4] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x5b as libc::c_int,
                handler: Some(input_input as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int),
                state: &input_state_dcs_handler as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x5c as libc::c_int,
                last: 0x5c as libc::c_int,
                handler: Some(
                    input_dcs_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x5d as libc::c_int,
                last: 0xff as libc::c_int,
                handler: Some(input_input as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int),
                state: &input_state_dcs_handler as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_dcs_ignore_table: [input_transition; 8] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0xff as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_osc_string_table: [input_transition; 10] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x6 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x7 as libc::c_int,
                last: 0x7 as libc::c_int,
                handler: Some(input_end_bel as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x8 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0xff as libc::c_int,
                handler: Some(input_input as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_apc_string_table: [input_transition; 8] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0xff as libc::c_int,
                handler: Some(input_input as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_rename_string_table: [input_transition; 8] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0xff as libc::c_int,
                handler: Some(input_input as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int),
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_state_consume_st_table: [input_transition; 8] = unsafe {
    [
        {
            let mut init = input_transition {
                first: 0x18 as libc::c_int,
                last: 0x18 as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1a as libc::c_int,
                last: 0x1a as libc::c_int,
                handler: Some(
                    input_c0_dispatch as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int,
                ),
                state: &input_state_ground as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1b as libc::c_int,
                last: 0x1b as libc::c_int,
                handler: None,
                state: &input_state_esc_enter as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0 as libc::c_int,
                last: 0x17 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x19 as libc::c_int,
                last: 0x19 as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x1c as libc::c_int,
                last: 0x1f as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: 0x20 as libc::c_int,
                last: 0xff as libc::c_int,
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
        {
            let mut init = input_transition {
                first: -(1 as libc::c_int),
                last: -(1 as libc::c_int),
                handler: None,
                state: 0 as *const input_state,
            };
            init
        },
    ]
};
static mut input_buffer_size: size_t = 1048576 as libc::c_int as size_t;
unsafe extern "C" fn input_table_compare(
    mut key: *const libc::c_void,
    mut value: *const libc::c_void,
) -> libc::c_int {
    let mut ictx: *const input_ctx = key as *const input_ctx;
    let mut entry: *const input_table_entry = value as *const input_table_entry;
    if (*ictx).ch != (*entry).ch {
        return (*ictx).ch - (*entry).ch;
    }
    return strcmp(
        ((*ictx).interm_buf).as_ptr() as *const libc::c_char,
        (*entry).interm,
    );
}
unsafe extern "C" fn input_timer_callback(
    mut fd: libc::c_int,
    mut events: libc::c_short,
    mut arg: *mut libc::c_void,
) {
    let mut ictx: *mut input_ctx = arg as *mut input_ctx;
    log_debug(
        b"%s: %s expired\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 21], &[libc::c_char; 21]>(b"input_timer_callback\0"))
            .as_ptr(),
        (*(*ictx).state).name,
    );
    input_reset(ictx, 0 as libc::c_int);
}
unsafe extern "C" fn input_start_timer(mut ictx: *mut input_ctx) {
    let mut tv: timeval = {
        let mut init = timeval {
            tv_sec: 5 as libc::c_int as __time_t,
            tv_usec: 0 as libc::c_int as __suseconds_t,
        };
        init
    };
    event_del(&mut (*ictx).timer);
    event_add(&mut (*ictx).timer, &mut tv);
}
unsafe extern "C" fn input_reset_cell(mut ictx: *mut input_ctx) {
    memcpy(
        &mut (*ictx).cell.cell as *mut grid_cell as *mut libc::c_void,
        &grid_default_cell as *const grid_cell as *const libc::c_void,
        ::core::mem::size_of::<grid_cell>() as libc::c_ulong,
    );
    (*ictx).cell.set = 0 as libc::c_int;
    (*ictx).cell.g1set = 0 as libc::c_int;
    (*ictx).cell.g0set = (*ictx).cell.g1set;
    memcpy(
        &mut (*ictx).old_cell as *mut input_cell as *mut libc::c_void,
        &mut (*ictx).cell as *mut input_cell as *const libc::c_void,
        ::core::mem::size_of::<input_cell>() as libc::c_ulong,
    );
    (*ictx).old_cx = 0 as libc::c_int as u_int;
    (*ictx).old_cy = 0 as libc::c_int as u_int;
}
unsafe extern "C" fn input_save_state(mut ictx: *mut input_ctx) {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut s: *mut screen = (*sctx).s;
    memcpy(
        &mut (*ictx).old_cell as *mut input_cell as *mut libc::c_void,
        &mut (*ictx).cell as *mut input_cell as *const libc::c_void,
        ::core::mem::size_of::<input_cell>() as libc::c_ulong,
    );
    (*ictx).old_cx = (*s).cx;
    (*ictx).old_cy = (*s).cy;
    (*ictx).old_mode = (*s).mode;
}
unsafe extern "C" fn input_restore_state(mut ictx: *mut input_ctx) {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    memcpy(
        &mut (*ictx).cell as *mut input_cell as *mut libc::c_void,
        &mut (*ictx).old_cell as *mut input_cell as *const libc::c_void,
        ::core::mem::size_of::<input_cell>() as libc::c_ulong,
    );
    if (*ictx).old_mode & 0x2000 as libc::c_int != 0 {
        screen_write_mode_set(sctx, 0x2000 as libc::c_int);
    } else {
        screen_write_mode_clear(sctx, 0x2000 as libc::c_int);
    }
    screen_write_cursormove(
        sctx,
        (*ictx).old_cx as libc::c_int,
        (*ictx).old_cy as libc::c_int,
        0 as libc::c_int,
    );
}
#[no_mangle]
pub unsafe extern "C" fn input_init(
    mut wp: *mut window_pane,
    mut bev: *mut bufferevent,
    mut palette: *mut colour_palette,
) -> *mut input_ctx {
    let mut ictx: *mut input_ctx = std::ptr::null_mut::<input_ctx>();
    ictx = xcalloc(
        1 as libc::c_int as size_t,
        ::core::mem::size_of::<input_ctx>() as libc::c_ulong,
    ) as *mut input_ctx;
    (*ictx).wp = wp;
    (*ictx).event = bev;
    (*ictx).palette = palette;
    (*ictx).input_space = 32 as libc::c_int as size_t;
    (*ictx).input_buf = xmalloc(32 as libc::c_int as size_t) as *mut u_char;
    (*ictx).since_ground = evbuffer_new();
    if ((*ictx).since_ground).is_null() {
        fatalx(b"out of memory\0" as *const u8 as *const libc::c_char);
    }
    event_set(
        &mut (*ictx).timer,
        -(1 as libc::c_int),
        0 as libc::c_int as libc::c_short,
        Some(
            input_timer_callback
                as unsafe extern "C" fn(libc::c_int, libc::c_short, *mut libc::c_void) -> (),
        ),
        ictx as *mut libc::c_void,
    );
    input_reset(ictx, 0 as libc::c_int);
    return ictx;
}
#[no_mangle]
pub unsafe extern "C" fn input_free(mut ictx: *mut input_ctx) {
    let mut i: u_int = 0;
    i = 0 as libc::c_int as u_int;
    while i < (*ictx).param_list_len {
        if (*ictx).param_list[i as usize].type_0 as libc::c_uint
            == INPUT_STRING as libc::c_int as libc::c_uint
        {
            free((*ictx).param_list[i as usize].c2rust_unnamed.str_0 as *mut libc::c_void);
        }
        i = i.wrapping_add(1);
    }
    event_del(&mut (*ictx).timer);
    free((*ictx).input_buf as *mut libc::c_void);
    evbuffer_free((*ictx).since_ground);
    free(ictx as *mut libc::c_void);
}
#[no_mangle]
pub unsafe extern "C" fn input_reset(mut ictx: *mut input_ctx, mut clear: libc::c_int) {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut wp: *mut window_pane = (*ictx).wp;
    input_reset_cell(ictx);
    if clear != 0 && !wp.is_null() {
        if ((*wp).modes.tqh_first).is_null() {
            screen_write_start_pane(sctx, wp, &mut (*wp).base);
        } else {
            screen_write_start(sctx, &mut (*wp).base);
        }
        screen_write_reset(sctx);
        screen_write_stop(sctx);
    }
    input_clear(ictx);
    (*ictx).state = &input_state_ground;
    (*ictx).flags = 0 as libc::c_int;
}
#[no_mangle]
pub unsafe extern "C" fn input_pending(mut ictx: *mut input_ctx) -> *mut evbuffer {
    return (*ictx).since_ground;
}
unsafe extern "C" fn input_set_state(mut ictx: *mut input_ctx, mut itr: *const input_transition) {
    if ((*(*ictx).state).exit).is_some() {
        ((*(*ictx).state).exit).expect("non-null function pointer")(ictx);
    }
    (*ictx).state = (*itr).state;
    if ((*(*ictx).state).enter).is_some() {
        ((*(*ictx).state).enter).expect("non-null function pointer")(ictx);
    }
}
unsafe extern "C" fn input_parse(mut ictx: *mut input_ctx, mut buf: *mut u_char, mut len: size_t) {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut state: *const input_state = std::ptr::null::<input_state>();
    let mut itr: *const input_transition = std::ptr::null::<input_transition>();
    let mut off: size_t = 0 as libc::c_int as size_t;
    while off < len {
        let fresh0 = off;
        off = off.wrapping_add(1);
        (*ictx).ch = *buf.offset(fresh0 as isize) as libc::c_int;
        if (*ictx).state != state
            || itr.is_null()
            || (*ictx).ch < (*itr).first
            || (*ictx).ch > (*itr).last
        {
            itr = (*(*ictx).state).transitions;
            while (*itr).first != -(1 as libc::c_int) && (*itr).last != -(1 as libc::c_int) {
                if (*ictx).ch >= (*itr).first && (*ictx).ch <= (*itr).last {
                    break;
                }
                itr = itr.offset(1);
            }
            if (*itr).first == -(1 as libc::c_int) || (*itr).last == -(1 as libc::c_int) {
                fatalx(b"no transition from state\0" as *const u8 as *const libc::c_char);
            }
        }
        state = (*ictx).state;
        if (*itr).handler
            != Some(input_print as unsafe extern "C" fn(*mut input_ctx) -> libc::c_int)
        {
            screen_write_collect_end(sctx);
        }
        if ((*itr).handler).is_some()
            && ((*itr).handler).expect("non-null function pointer")(ictx) != 0 as libc::c_int
        {
            continue;
        }
        if !((*itr).state).is_null() {
            input_set_state(ictx, itr);
        }
        if (*ictx).state != &input_state_ground as *const input_state {
            evbuffer_add(
                (*ictx).since_ground,
                &mut (*ictx).ch as *mut libc::c_int as *const libc::c_void,
                1 as libc::c_int as size_t,
            );
        }
    }
}
#[no_mangle]
pub unsafe extern "C" fn input_parse_pane(mut wp: *mut window_pane) {
    let mut new_data: *mut libc::c_void = std::ptr::null_mut::<libc::c_void>();
    let mut new_size: size_t = 0;
    new_data = window_pane_get_new_data(wp, &mut (*wp).offset, &mut new_size);
    input_parse_buffer(wp, new_data as *mut u_char, new_size);
    window_pane_update_used_data(wp, &mut (*wp).offset, new_size);
}
#[no_mangle]
pub unsafe extern "C" fn input_parse_buffer(
    mut wp: *mut window_pane,
    mut buf: *mut u_char,
    mut len: size_t,
) {
    let mut ictx: *mut input_ctx = (*wp).ictx;
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    if len == 0 as libc::c_int as libc::c_ulong {
        return;
    }
    window_update_activity((*wp).window);
    (*wp).flags |= 0x80 as libc::c_int;
    if !((*wp).modes.tqh_first).is_null() {
        (*wp).flags |= 0x2000 as libc::c_int;
    }
    if ((*wp).modes.tqh_first).is_null() {
        screen_write_start_pane(sctx, wp, &mut (*wp).base);
    } else {
        screen_write_start(sctx, &mut (*wp).base);
    }
    log_debug(
        b"%s: %%%u %s, %zu bytes: %.*s\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(b"input_parse_buffer\0"))
            .as_ptr(),
        (*wp).id,
        (*(*ictx).state).name,
        len,
        len as libc::c_int,
        buf,
    );
    input_parse(ictx, buf, len);
    screen_write_stop(sctx);
}
#[no_mangle]
pub unsafe extern "C" fn input_parse_screen(
    mut ictx: *mut input_ctx,
    mut s: *mut screen,
    mut cb: screen_write_init_ctx_cb,
    mut arg: *mut libc::c_void,
    mut buf: *mut u_char,
    mut len: size_t,
) {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    if len == 0 as libc::c_int as libc::c_ulong {
        return;
    }
    screen_write_start_callback(sctx, s, cb, arg);
    input_parse(ictx, buf, len);
    screen_write_stop(sctx);
}
unsafe extern "C" fn input_split(mut ictx: *mut input_ctx) -> libc::c_int {
    let mut errstr: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut ptr: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut out: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut ip: *mut input_param = std::ptr::null_mut::<input_param>();
    let mut i: u_int = 0;
    i = 0 as libc::c_int as u_int;
    while i < (*ictx).param_list_len {
        if (*ictx).param_list[i as usize].type_0 as libc::c_uint
            == INPUT_STRING as libc::c_int as libc::c_uint
        {
            free((*ictx).param_list[i as usize].c2rust_unnamed.str_0 as *mut libc::c_void);
        }
        i = i.wrapping_add(1);
    }
    (*ictx).param_list_len = 0 as libc::c_int as u_int;
    if (*ictx).param_len == 0 as libc::c_int as libc::c_ulong {
        return 0 as libc::c_int;
    }
    ip = &mut *((*ictx).param_list)
        .as_mut_ptr()
        .offset(0 as libc::c_int as isize) as *mut input_param;
    ptr = ((*ictx).param_buf).as_mut_ptr() as *mut libc::c_char;
    loop {
        out = strsep(&mut ptr, b";\0" as *const u8 as *const libc::c_char);
        if out.is_null() {
            break;
        }
        if *out as libc::c_int == '\0' as i32 {
            (*ip).type_0 = INPUT_MISSING;
        } else if !(strchr(out, ':' as i32)).is_null() {
            (*ip).type_0 = INPUT_STRING;
            (*ip).c2rust_unnamed.str_0 = xstrdup(out);
        } else {
            (*ip).type_0 = INPUT_NUMBER;
            (*ip).c2rust_unnamed.num = strtonum(
                out,
                0 as libc::c_int as libc::c_longlong,
                2147483647 as libc::c_int as libc::c_longlong,
                &mut errstr,
            ) as libc::c_int;
            if !errstr.is_null() {
                return -(1 as libc::c_int);
            }
        }
        (*ictx).param_list_len = ((*ictx).param_list_len).wrapping_add(1);
        ip = &mut *((*ictx).param_list)
            .as_mut_ptr()
            .offset((*ictx).param_list_len as isize) as *mut input_param;
        if (*ictx).param_list_len as libc::c_ulong
            == (::core::mem::size_of::<[input_param; 24]>() as libc::c_ulong)
                .wrapping_div(::core::mem::size_of::<input_param>() as libc::c_ulong)
        {
            return -(1 as libc::c_int);
        }
    }
    i = 0 as libc::c_int as u_int;
    while i < (*ictx).param_list_len {
        ip = &mut *((*ictx).param_list).as_mut_ptr().offset(i as isize) as *mut input_param;
        if (*ip).type_0 as libc::c_uint == INPUT_MISSING as libc::c_int as libc::c_uint {
            log_debug(
                b"parameter %u: missing\0" as *const u8 as *const libc::c_char,
                i,
            );
        } else if (*ip).type_0 as libc::c_uint == INPUT_STRING as libc::c_int as libc::c_uint {
            log_debug(
                b"parameter %u: string %s\0" as *const u8 as *const libc::c_char,
                i,
                (*ip).c2rust_unnamed.str_0,
            );
        } else if (*ip).type_0 as libc::c_uint == INPUT_NUMBER as libc::c_int as libc::c_uint {
            log_debug(
                b"parameter %u: number %d\0" as *const u8 as *const libc::c_char,
                i,
                (*ip).c2rust_unnamed.num,
            );
        }
        i = i.wrapping_add(1);
    }
    return 0 as libc::c_int;
}
unsafe extern "C" fn input_get(
    mut ictx: *mut input_ctx,
    mut validx: u_int,
    mut minval: libc::c_int,
    mut defval: libc::c_int,
) -> libc::c_int {
    let mut ip: *mut input_param = std::ptr::null_mut::<input_param>();
    let mut retval: libc::c_int = 0;
    if validx >= (*ictx).param_list_len {
        return defval;
    }
    ip = &mut *((*ictx).param_list).as_mut_ptr().offset(validx as isize) as *mut input_param;
    if (*ip).type_0 as libc::c_uint == INPUT_MISSING as libc::c_int as libc::c_uint {
        return defval;
    }
    if (*ip).type_0 as libc::c_uint == INPUT_STRING as libc::c_int as libc::c_uint {
        return -(1 as libc::c_int);
    }
    retval = (*ip).c2rust_unnamed.num;
    if retval < minval {
        return minval;
    }
    return retval;
}
unsafe extern "C" fn input_reply(
    mut ictx: *mut input_ctx,
    mut fmt: *const libc::c_char,
    mut args: ...
) {
    let mut bev: *mut bufferevent = (*ictx).event;
    let mut ap: ::core::ffi::VaListImpl;
    let mut reply: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if bev.is_null() {
        return;
    }
    ap = args.clone();
    xvasprintf(&mut reply, fmt, ap.as_va_list());
    log_debug(
        b"%s: %s\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 12], &[libc::c_char; 12]>(b"input_reply\0")).as_ptr(),
        reply,
    );
    bufferevent_write(bev, reply as *const libc::c_void, strlen(reply));
    free(reply as *mut libc::c_void);
}
unsafe extern "C" fn input_clear(mut ictx: *mut input_ctx) {
    event_del(&mut (*ictx).timer);
    *((*ictx).interm_buf).as_mut_ptr() = '\0' as i32 as u_char;
    (*ictx).interm_len = 0 as libc::c_int as size_t;
    *((*ictx).param_buf).as_mut_ptr() = '\0' as i32 as u_char;
    (*ictx).param_len = 0 as libc::c_int as size_t;
    *(*ictx).input_buf = '\0' as i32 as u_char;
    (*ictx).input_len = 0 as libc::c_int as size_t;
    (*ictx).input_end = INPUT_END_ST;
    (*ictx).flags &= !(0x1 as libc::c_int);
}
unsafe extern "C" fn input_ground(mut ictx: *mut input_ctx) {
    event_del(&mut (*ictx).timer);
    evbuffer_drain(
        (*ictx).since_ground,
        evbuffer_get_length((*ictx).since_ground),
    );
    if (*ictx).input_space > 32 as libc::c_int as libc::c_ulong {
        (*ictx).input_space = 32 as libc::c_int as size_t;
        (*ictx).input_buf = xrealloc(
            (*ictx).input_buf as *mut libc::c_void,
            32 as libc::c_int as size_t,
        ) as *mut u_char;
    }
}
unsafe extern "C" fn input_print(mut ictx: *mut input_ctx) -> libc::c_int {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut set: libc::c_int = 0;
    (*ictx).utf8started = 0 as libc::c_int;
    set = if (*ictx).cell.set == 0 as libc::c_int {
        (*ictx).cell.g0set
    } else {
        (*ictx).cell.g1set
    };
    if set == 1 as libc::c_int {
        (*ictx).cell.cell.attr =
            ((*ictx).cell.cell.attr as libc::c_int | 0x80 as libc::c_int) as u_short;
    } else {
        (*ictx).cell.cell.attr =
            ((*ictx).cell.cell.attr as libc::c_int & !(0x80 as libc::c_int)) as u_short;
    }
    utf8_set(&mut (*ictx).cell.cell.data, (*ictx).ch as u_char);
    screen_write_collect_add(sctx, &mut (*ictx).cell.cell);
    utf8_copy(&mut (*ictx).last, &mut (*ictx).cell.cell.data);
    (*ictx).flags |= 0x2 as libc::c_int;
    (*ictx).cell.cell.attr =
        ((*ictx).cell.cell.attr as libc::c_int & !(0x80 as libc::c_int)) as u_short;
    return 0 as libc::c_int;
}
unsafe extern "C" fn input_intermediate(mut ictx: *mut input_ctx) -> libc::c_int {
    if (*ictx).interm_len
        == (::core::mem::size_of::<[u_char; 4]>() as libc::c_ulong)
            .wrapping_sub(1 as libc::c_int as libc::c_ulong)
    {
        (*ictx).flags |= 0x1 as libc::c_int;
    } else {
        let fresh1 = (*ictx).interm_len;
        (*ictx).interm_len = ((*ictx).interm_len).wrapping_add(1);
        (*ictx).interm_buf[fresh1 as usize] = (*ictx).ch as u_char;
        (*ictx).interm_buf[(*ictx).interm_len as usize] = '\0' as i32 as u_char;
    }
    return 0 as libc::c_int;
}
unsafe extern "C" fn input_parameter(mut ictx: *mut input_ctx) -> libc::c_int {
    if (*ictx).param_len
        == (::core::mem::size_of::<[u_char; 64]>() as libc::c_ulong)
            .wrapping_sub(1 as libc::c_int as libc::c_ulong)
    {
        (*ictx).flags |= 0x1 as libc::c_int;
    } else {
        let fresh2 = (*ictx).param_len;
        (*ictx).param_len = ((*ictx).param_len).wrapping_add(1);
        (*ictx).param_buf[fresh2 as usize] = (*ictx).ch as u_char;
        (*ictx).param_buf[(*ictx).param_len as usize] = '\0' as i32 as u_char;
    }
    return 0 as libc::c_int;
}
unsafe extern "C" fn input_input(mut ictx: *mut input_ctx) -> libc::c_int {
    let mut available: size_t = 0;
    available = (*ictx).input_space;
    while ((*ictx).input_len).wrapping_add(1 as libc::c_int as libc::c_ulong) >= available {
        available = (available as libc::c_ulong).wrapping_mul(2 as libc::c_int as libc::c_ulong)
            as size_t as size_t;
        if available > input_buffer_size {
            (*ictx).flags |= 0x1 as libc::c_int;
            return 0 as libc::c_int;
        }
        (*ictx).input_buf =
            xrealloc((*ictx).input_buf as *mut libc::c_void, available) as *mut u_char;
        (*ictx).input_space = available;
    }
    let fresh3 = (*ictx).input_len;
    (*ictx).input_len = ((*ictx).input_len).wrapping_add(1);
    *((*ictx).input_buf).offset(fresh3 as isize) = (*ictx).ch as u_char;
    *((*ictx).input_buf).offset((*ictx).input_len as isize) = '\0' as i32 as u_char;
    return 0 as libc::c_int;
}
unsafe extern "C" fn input_c0_dispatch(mut ictx: *mut input_ctx) -> libc::c_int {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut wp: *mut window_pane = (*ictx).wp;
    let mut s: *mut screen = (*sctx).s;
    let mut gc: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    let mut first_gc: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    let mut cx: u_int = (*s).cx;
    let mut line: u_int = ((*s).cy).wrapping_add((*(*s).grid).hsize);
    let mut width: u_int = 0;
    let mut has_content: libc::c_int = 0 as libc::c_int;
    (*ictx).utf8started = 0 as libc::c_int;
    log_debug(
        b"%s: '%c'\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 18], &[libc::c_char; 18]>(b"input_c0_dispatch\0"))
            .as_ptr(),
        (*ictx).ch,
    );
    let mut current_block_26: u64;
    match (*ictx).ch {
        0 => {
            current_block_26 = 17500079516916021833;
        }
        7 => {
            if !wp.is_null() {
                alerts_queue((*wp).window, 0x1 as libc::c_int);
            }
            current_block_26 = 17500079516916021833;
        }
        8 => {
            screen_write_backspace(sctx);
            current_block_26 = 17500079516916021833;
        }
        9 => {
            if (*s).cx >= ((*(*s).grid).sx).wrapping_sub(1 as libc::c_int as libc::c_uint) {
                current_block_26 = 17500079516916021833;
            } else {
                grid_get_cell((*s).grid, (*s).cx, line, &mut first_gc);
                loop {
                    if has_content == 0 {
                        grid_get_cell((*s).grid, cx, line, &mut gc);
                        if gc.data.size as libc::c_int != 1 as libc::c_int
                            || *(gc.data.data).as_mut_ptr() as libc::c_int != ' ' as i32
                            || grid_cells_look_equal(&mut gc, &mut first_gc) == 0
                        {
                            has_content = 1 as libc::c_int;
                        }
                    }
                    cx = cx.wrapping_add(1);
                    if *((*s).tabs).offset((cx >> 3 as libc::c_int) as isize) as libc::c_int
                        & (1 as libc::c_int) << (cx & 0x7 as libc::c_int as libc::c_uint)
                        != 0
                    {
                        break;
                    }
                    if cx >= ((*(*s).grid).sx).wrapping_sub(1 as libc::c_int as libc::c_uint) {
                        break;
                    }
                }
                width = cx.wrapping_sub((*s).cx);
                if has_content != 0
                    || width as libc::c_ulong
                        > ::core::mem::size_of::<[u_char; 21]>() as libc::c_ulong
                {
                    (*s).cx = cx;
                } else {
                    grid_get_cell((*s).grid, (*s).cx, line, &mut gc);
                    grid_set_tab(&mut gc, width);
                    screen_write_collect_add(sctx, &mut gc);
                }
                current_block_26 = 17500079516916021833;
            }
        }
        11 => {
            current_block_26 = 11710430428370658471;
        }
        10 | 12 => {
            current_block_26 = 11710430428370658471;
        }
        13 => {
            screen_write_carriagereturn(sctx);
            current_block_26 = 17500079516916021833;
        }
        14 => {
            (*ictx).cell.set = 1 as libc::c_int;
            current_block_26 = 17500079516916021833;
        }
        15 => {
            (*ictx).cell.set = 0 as libc::c_int;
            current_block_26 = 17500079516916021833;
        }
        _ => {
            log_debug(
                b"%s: unknown '%c'\0" as *const u8 as *const libc::c_char,
                (*::core::mem::transmute::<&[u8; 18], &[libc::c_char; 18]>(b"input_c0_dispatch\0"))
                    .as_ptr(),
                (*ictx).ch,
            );
            current_block_26 = 17500079516916021833;
        }
    }
    match current_block_26 {
        11710430428370658471 => {
            screen_write_linefeed(sctx, 0 as libc::c_int, (*ictx).cell.cell.bg as u_int);
            if (*s).mode & 0x4000 as libc::c_int != 0 {
                screen_write_carriagereturn(sctx);
            }
        }
        _ => {}
    }
    (*ictx).flags &= !(0x2 as libc::c_int);
    return 0 as libc::c_int;
}
unsafe extern "C" fn input_esc_dispatch(mut ictx: *mut input_ctx) -> libc::c_int {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut s: *mut screen = (*sctx).s;
    let mut entry: *mut input_table_entry = std::ptr::null_mut::<input_table_entry>();
    if (*ictx).flags & 0x1 as libc::c_int != 0 {
        return 0 as libc::c_int;
    }
    log_debug(
        b"%s: '%c', %s\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(b"input_esc_dispatch\0"))
            .as_ptr(),
        (*ictx).ch,
        ((*ictx).interm_buf).as_mut_ptr(),
    );
    entry = bsearch(
        ictx as *const libc::c_void,
        input_esc_table.as_ptr() as *const libc::c_void,
        (::core::mem::size_of::<[input_table_entry; 15]>() as libc::c_ulong)
            .wrapping_div(::core::mem::size_of::<input_table_entry>() as libc::c_ulong),
        ::core::mem::size_of::<input_table_entry>() as libc::c_ulong,
        Some(
            input_table_compare
                as unsafe extern "C" fn(*const libc::c_void, *const libc::c_void) -> libc::c_int,
        ),
    ) as *mut input_table_entry;
    if entry.is_null() {
        log_debug(
            b"%s: unknown '%c'\0" as *const u8 as *const libc::c_char,
            (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(b"input_esc_dispatch\0"))
                .as_ptr(),
            (*ictx).ch,
        );
        return 0 as libc::c_int;
    }
    match (*entry).type_0 {
        9 => {
            colour_palette_clear((*ictx).palette);
            input_reset_cell(ictx);
            screen_write_reset(sctx);
            screen_write_fullredraw(sctx);
        }
        6 => {
            screen_write_linefeed(sctx, 0 as libc::c_int, (*ictx).cell.cell.bg as u_int);
        }
        7 => {
            screen_write_carriagereturn(sctx);
            screen_write_linefeed(sctx, 0 as libc::c_int, (*ictx).cell.cell.bg as u_int);
        }
        5 => {
            if (*s).cx < (*(*s).grid).sx {
                let fresh4 = &mut (*((*s).tabs).offset(((*s).cx >> 3 as libc::c_int) as isize));
                *fresh4 = (*fresh4 as libc::c_int
                    | (1 as libc::c_int) << ((*s).cx & 0x7 as libc::c_int as libc::c_uint))
                    as bitstr_t;
            }
        }
        8 => {
            screen_write_reverseindex(sctx, (*ictx).cell.cell.bg as u_int);
        }
        1 => {
            screen_write_mode_set(sctx, 0x8 as libc::c_int);
        }
        2 => {
            screen_write_mode_clear(sctx, 0x8 as libc::c_int);
        }
        4 => {
            input_save_state(ictx);
        }
        3 => {
            input_restore_state(ictx);
        }
        0 => {
            screen_write_alignmenttest(sctx);
        }
        11 => {
            (*ictx).cell.g0set = 1 as libc::c_int;
        }
        10 => {
            (*ictx).cell.g0set = 0 as libc::c_int;
        }
        13 => {
            (*ictx).cell.g1set = 1 as libc::c_int;
        }
        12 => {
            (*ictx).cell.g1set = 0 as libc::c_int;
        }
        14 | _ => {}
    }
    (*ictx).flags &= !(0x2 as libc::c_int);
    return 0 as libc::c_int;
}
unsafe extern "C" fn input_csi_dispatch(mut ictx: *mut input_ctx) -> libc::c_int {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut s: *mut screen = (*sctx).s;
    let mut entry: *mut input_table_entry = std::ptr::null_mut::<input_table_entry>();
    let mut i: libc::c_int = 0;
    let mut n: libc::c_int = 0;
    let mut m: libc::c_int = 0;
    let mut ek: libc::c_int = 0;
    let mut set: libc::c_int = 0;
    let mut cx: u_int = 0;
    let mut bg: u_int = (*ictx).cell.cell.bg as u_int;
    if (*ictx).flags & 0x1 as libc::c_int != 0 {
        return 0 as libc::c_int;
    }
    log_debug(
        b"%s: '%c' \"%s\" \"%s\"\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(b"input_csi_dispatch\0"))
            .as_ptr(),
        (*ictx).ch,
        ((*ictx).interm_buf).as_mut_ptr(),
        ((*ictx).param_buf).as_mut_ptr(),
    );
    if input_split(ictx) != 0 as libc::c_int {
        return 0 as libc::c_int;
    }
    entry = bsearch(
        ictx as *const libc::c_void,
        input_csi_table.as_ptr() as *const libc::c_void,
        (::core::mem::size_of::<[input_table_entry; 40]>() as libc::c_ulong)
            .wrapping_div(::core::mem::size_of::<input_table_entry>() as libc::c_ulong),
        ::core::mem::size_of::<input_table_entry>() as libc::c_ulong,
        Some(
            input_table_compare
                as unsafe extern "C" fn(*const libc::c_void, *const libc::c_void) -> libc::c_int,
        ),
    ) as *mut input_table_entry;
    if entry.is_null() {
        log_debug(
            b"%s: unknown '%c'\0" as *const u8 as *const libc::c_char,
            (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(b"input_csi_dispatch\0"))
                .as_ptr(),
            (*ictx).ch,
        );
        return 0 as libc::c_int;
    }
    match (*entry).type_0 {
        0 => {
            cx = (*s).cx;
            if cx > ((*(*s).grid).sx).wrapping_sub(1 as libc::c_int as libc::c_uint) {
                cx = ((*(*s).grid).sx).wrapping_sub(1 as libc::c_int as libc::c_uint);
            }
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                while cx > 0 as libc::c_int as libc::c_uint && {
                    let fresh5 = n;
                    n = n - 1;
                    fresh5 > 0 as libc::c_int
                } {
                    loop {
                        cx = cx.wrapping_sub(1);
                        if !(cx > 0 as libc::c_int as libc::c_uint
                            && *((*s).tabs).offset((cx >> 3 as libc::c_int) as isize)
                                as libc::c_int
                                & (1 as libc::c_int) << (cx & 0x7 as libc::c_int as libc::c_uint)
                                == 0)
                        {
                            break;
                        }
                    }
                }
                (*s).cx = cx;
            }
        }
        3 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_cursorleft(sctx, n as u_int);
            }
        }
        4 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_cursordown(sctx, n as u_int);
            }
        }
        5 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_cursorright(sctx, n as u_int);
            }
        }
        6 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            m = input_get(
                ictx,
                1 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) && m != -(1 as libc::c_int) {
                screen_write_cursormove(
                    sctx,
                    m - 1 as libc::c_int,
                    n - 1 as libc::c_int,
                    1 as libc::c_int,
                );
            }
        }
        22 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                0 as libc::c_int,
                0 as libc::c_int,
            );
            if n == 4 as libc::c_int {
                m = input_get(
                    ictx,
                    1 as libc::c_int as u_int,
                    0 as libc::c_int,
                    0 as libc::c_int,
                );
                ek = options_get_number(
                    global_options,
                    b"extended-keys\0" as *const u8 as *const libc::c_char,
                ) as libc::c_int;
                if ek != 0 as libc::c_int {
                    screen_write_mode_clear(sctx, 0x8000 as libc::c_int | 0x40000 as libc::c_int);
                    if m == 2 as libc::c_int {
                        screen_write_mode_set(sctx, 0x40000 as libc::c_int);
                    } else if m == 1 as libc::c_int || ek == 2 as libc::c_int {
                        screen_write_mode_set(sctx, 0x8000 as libc::c_int);
                    }
                }
            }
        }
        21 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                0 as libc::c_int,
                0 as libc::c_int,
            );
            if n == 4 as libc::c_int {
                screen_write_mode_clear(sctx, 0x8000 as libc::c_int | 0x40000 as libc::c_int);
                if options_get_number(
                    global_options,
                    b"extended-keys\0" as *const u8 as *const libc::c_char,
                ) == 2 as libc::c_int as libc::c_longlong
                {
                    screen_write_mode_set(sctx, 0x8000 as libc::c_int);
                }
            }
        }
        36 => {
            input_csi_dispatch_winops(ictx);
        }
        7 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_cursorup(sctx, n as u_int);
            }
        }
        1 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_carriagereturn(sctx);
                screen_write_cursordown(sctx, n as u_int);
            }
        }
        2 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_carriagereturn(sctx);
                screen_write_cursorup(sctx, n as u_int);
            }
        }
        8 => {
            match input_get(
                ictx,
                0 as libc::c_int as u_int,
                0 as libc::c_int,
                0 as libc::c_int,
            ) {
                -1 => {}
                0 => {
                    input_reply(ictx, b"\x1B[?1;2c\0" as *const u8 as *const libc::c_char);
                }
                _ => {
                    log_debug(
                        b"%s: unknown '%c'\0" as *const u8 as *const libc::c_char,
                        (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(
                            b"input_csi_dispatch\0",
                        ))
                        .as_ptr(),
                        (*ictx).ch,
                    );
                }
            }
        }
        9 => {
            match input_get(
                ictx,
                0 as libc::c_int as u_int,
                0 as libc::c_int,
                0 as libc::c_int,
            ) {
                -1 => {}
                0 => {
                    input_reply(ictx, b"\x1B[>84;0;0c\0" as *const u8 as *const libc::c_char);
                }
                _ => {
                    log_debug(
                        b"%s: unknown '%c'\0" as *const u8 as *const libc::c_char,
                        (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(
                            b"input_csi_dispatch\0",
                        ))
                        .as_ptr(),
                        (*ictx).ch,
                    );
                }
            }
        }
        15 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_clearcharacter(sctx, n as u_int, bg);
            }
        }
        10 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_deletecharacter(sctx, n as u_int, bg);
            }
        }
        12 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            m = input_get(
                ictx,
                1 as libc::c_int as u_int,
                1 as libc::c_int,
                (*(*s).grid).sy as libc::c_int,
            );
            if n != -(1 as libc::c_int) && m != -(1 as libc::c_int) {
                screen_write_scrollregion(
                    sctx,
                    (n - 1 as libc::c_int) as u_int,
                    (m - 1 as libc::c_int) as u_int,
                );
            }
        }
        13 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_deleteline(sctx, n as u_int, bg);
            }
        }
        14 => {
            match input_get(
                ictx,
                0 as libc::c_int as u_int,
                0 as libc::c_int,
                0 as libc::c_int,
            ) {
                -1 => {}
                5 => {
                    input_reply(ictx, b"\x1B[0n\0" as *const u8 as *const libc::c_char);
                }
                6 => {
                    input_reply(
                        ictx,
                        b"\x1B[%u;%uR\0" as *const u8 as *const libc::c_char,
                        ((*s).cy).wrapping_add(1 as libc::c_int as libc::c_uint),
                        ((*s).cx).wrapping_add(1 as libc::c_int as libc::c_uint),
                    );
                }
                _ => {
                    log_debug(
                        b"%s: unknown '%c'\0" as *const u8 as *const libc::c_char,
                        (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(
                            b"input_csi_dispatch\0",
                        ))
                        .as_ptr(),
                        (*ictx).ch,
                    );
                }
            }
        }
        16 => {
            match input_get(
                ictx,
                0 as libc::c_int as u_int,
                0 as libc::c_int,
                0 as libc::c_int,
            ) {
                -1 => {}
                0 => {
                    screen_write_clearendofscreen(sctx, bg);
                }
                1 => {
                    screen_write_clearstartofscreen(sctx, bg);
                }
                2 => {
                    screen_write_clearscreen(sctx, bg);
                }
                3 => {
                    if input_get(
                        ictx,
                        1 as libc::c_int as u_int,
                        0 as libc::c_int,
                        0 as libc::c_int,
                    ) == 0 as libc::c_int
                    {
                        screen_write_clearhistory(sctx);
                    }
                }
                _ => {
                    log_debug(
                        b"%s: unknown '%c'\0" as *const u8 as *const libc::c_char,
                        (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(
                            b"input_csi_dispatch\0",
                        ))
                        .as_ptr(),
                        (*ictx).ch,
                    );
                }
            }
        }
        17 => {
            match input_get(
                ictx,
                0 as libc::c_int as u_int,
                0 as libc::c_int,
                0 as libc::c_int,
            ) {
                -1 => {}
                0 => {
                    screen_write_clearendofline(sctx, bg);
                }
                1 => {
                    screen_write_clearstartofline(sctx, bg);
                }
                2 => {
                    screen_write_clearline(sctx, bg);
                }
                _ => {
                    log_debug(
                        b"%s: unknown '%c'\0" as *const u8 as *const libc::c_char,
                        (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(
                            b"input_csi_dispatch\0",
                        ))
                        .as_ptr(),
                        (*ictx).ch,
                    );
                }
            }
        }
        18 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_cursormove(
                    sctx,
                    n - 1 as libc::c_int,
                    -(1 as libc::c_int),
                    1 as libc::c_int,
                );
            }
        }
        19 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_insertcharacter(sctx, n as u_int, bg);
            }
        }
        20 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_insertline(sctx, n as u_int, bg);
            }
        }
        24 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                m = ((*(*s).grid).sx).wrapping_sub((*s).cx) as libc::c_int;
                if n > m {
                    n = m;
                }
                if !(*ictx).flags & 0x2 as libc::c_int == 0 {
                    set = if (*ictx).cell.set == 0 as libc::c_int {
                        (*ictx).cell.g0set
                    } else {
                        (*ictx).cell.g1set
                    };
                    if set == 1 as libc::c_int {
                        (*ictx).cell.cell.attr = ((*ictx).cell.cell.attr as libc::c_int
                            | 0x80 as libc::c_int)
                            as u_short;
                    } else {
                        (*ictx).cell.cell.attr = ((*ictx).cell.cell.attr as libc::c_int
                            & !(0x80 as libc::c_int))
                            as u_short;
                    }
                    utf8_copy(&mut (*ictx).cell.cell.data, &mut (*ictx).last);
                    i = 0 as libc::c_int;
                    while i < n {
                        screen_write_collect_add(sctx, &mut (*ictx).cell.cell);
                        i += 1;
                    }
                }
            }
        }
        23 => {
            input_restore_state(ictx);
        }
        25 => {
            input_csi_dispatch_rm(ictx);
        }
        26 => {
            input_csi_dispatch_rm_private(ictx);
        }
        27 => {
            input_save_state(ictx);
        }
        29 => {
            input_csi_dispatch_sgr(ictx);
        }
        30 => {
            input_csi_dispatch_sm(ictx);
        }
        31 => {
            input_csi_dispatch_sm_private(ictx);
        }
        32 => {
            input_csi_dispatch_sm_graphics(ictx);
        }
        33 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_scrollup(sctx, n as u_int, bg);
            }
        }
        28 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_scrolldown(sctx, n as u_int, bg);
            }
        }
        34 => {
            match input_get(
                ictx,
                0 as libc::c_int as u_int,
                0 as libc::c_int,
                0 as libc::c_int,
            ) {
                -1 => {}
                0 => {
                    if (*s).cx < (*(*s).grid).sx {
                        let fresh6 =
                            &mut (*((*s).tabs).offset(((*s).cx >> 3 as libc::c_int) as isize));
                        *fresh6 = (*fresh6 as libc::c_int
                            & !((1 as libc::c_int)
                                << ((*s).cx & 0x7 as libc::c_int as libc::c_uint)))
                            as bitstr_t;
                    }
                }
                3 => {
                    let mut _name: *mut bitstr_t = (*s).tabs;
                    let mut _start: libc::c_int = 0 as libc::c_int;
                    let mut _stop: libc::c_int = ((*(*s).grid).sx)
                        .wrapping_sub(1 as libc::c_int as libc::c_uint)
                        as libc::c_int;
                    while _start <= _stop {
                        let fresh7 = &mut (*_name.offset((_start >> 3 as libc::c_int) as isize));
                        *fresh7 = (*fresh7 as libc::c_int
                            & !((1 as libc::c_int) << (_start & 0x7 as libc::c_int)))
                            as bitstr_t;
                        _start += 1;
                    }
                }
                _ => {
                    log_debug(
                        b"%s: unknown '%c'\0" as *const u8 as *const libc::c_char,
                        (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(
                            b"input_csi_dispatch\0",
                        ))
                        .as_ptr(),
                        (*ictx).ch,
                    );
                }
            }
        }
        35 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                1 as libc::c_int,
                1 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_write_cursormove(
                    sctx,
                    -(1 as libc::c_int),
                    n - 1 as libc::c_int,
                    1 as libc::c_int,
                );
            }
        }
        11 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                0 as libc::c_int,
                0 as libc::c_int,
            );
            if n != -(1 as libc::c_int) {
                screen_set_cursor_style(n as u_int, &mut (*s).cstyle, &mut (*s).mode);
            }
        }
        37 => {
            n = input_get(
                ictx,
                0 as libc::c_int as u_int,
                0 as libc::c_int,
                0 as libc::c_int,
            );
            if n == 0 as libc::c_int {
                input_reply(
                    ictx,
                    b"\x1BP>|tmux %s\x1B\\\0" as *const u8 as *const libc::c_char,
                    getversion(),
                );
            }
        }
        _ => {}
    }
    (*ictx).flags &= !(0x2 as libc::c_int);
    return 0 as libc::c_int;
}
unsafe extern "C" fn input_csi_dispatch_rm(mut ictx: *mut input_ctx) {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut i: u_int = 0;
    i = 0 as libc::c_int as u_int;
    while i < (*ictx).param_list_len {
        match input_get(ictx, i, 0 as libc::c_int, -(1 as libc::c_int)) {
            -1 => {}
            4 => {
                screen_write_mode_clear(sctx, 0x2 as libc::c_int);
            }
            34 => {
                screen_write_mode_set(sctx, 0x10000 as libc::c_int);
            }
            _ => {
                log_debug(
                    b"%s: unknown '%c'\0" as *const u8 as *const libc::c_char,
                    (*::core::mem::transmute::<&[u8; 22], &[libc::c_char; 22]>(
                        b"input_csi_dispatch_rm\0",
                    ))
                    .as_ptr(),
                    (*ictx).ch,
                );
            }
        }
        i = i.wrapping_add(1);
    }
}
unsafe extern "C" fn input_csi_dispatch_rm_private(mut ictx: *mut input_ctx) {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut gc: *mut grid_cell = &mut (*ictx).cell.cell;
    let mut i: u_int = 0;
    i = 0 as libc::c_int as u_int;
    while i < (*ictx).param_list_len {
        match input_get(ictx, i, 0 as libc::c_int, -(1 as libc::c_int)) {
            -1 => {}
            1 => {
                screen_write_mode_clear(sctx, 0x4 as libc::c_int);
            }
            3 => {
                screen_write_cursormove(sctx, 0 as libc::c_int, 0 as libc::c_int, 1 as libc::c_int);
                screen_write_clearscreen(sctx, (*gc).bg as u_int);
            }
            6 => {
                screen_write_mode_clear(sctx, 0x2000 as libc::c_int);
                screen_write_cursormove(sctx, 0 as libc::c_int, 0 as libc::c_int, 1 as libc::c_int);
            }
            7 => {
                screen_write_mode_clear(sctx, 0x10 as libc::c_int);
            }
            12 => {
                screen_write_mode_clear(sctx, 0x80 as libc::c_int);
                screen_write_mode_set(sctx, 0x20000 as libc::c_int);
            }
            25 => {
                screen_write_mode_clear(sctx, 0x1 as libc::c_int);
            }
            1000 | 1001 | 1002 | 1003 => {
                screen_write_mode_clear(
                    sctx,
                    0x20 as libc::c_int | 0x40 as libc::c_int | 0x1000 as libc::c_int,
                );
            }
            1004 => {
                screen_write_mode_clear(sctx, 0x800 as libc::c_int);
            }
            1005 => {
                screen_write_mode_clear(sctx, 0x100 as libc::c_int);
            }
            1006 => {
                screen_write_mode_clear(sctx, 0x200 as libc::c_int);
            }
            47 | 1047 => {
                screen_write_alternateoff(sctx, gc, 0 as libc::c_int);
            }
            1049 => {
                screen_write_alternateoff(sctx, gc, 1 as libc::c_int);
            }
            2004 => {
                screen_write_mode_clear(sctx, 0x400 as libc::c_int);
            }
            _ => {
                log_debug(
                    b"%s: unknown '%c'\0" as *const u8 as *const libc::c_char,
                    (*::core::mem::transmute::<&[u8; 30], &[libc::c_char; 30]>(
                        b"input_csi_dispatch_rm_private\0",
                    ))
                    .as_ptr(),
                    (*ictx).ch,
                );
            }
        }
        i = i.wrapping_add(1);
    }
}
unsafe extern "C" fn input_csi_dispatch_sm(mut ictx: *mut input_ctx) {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut i: u_int = 0;
    i = 0 as libc::c_int as u_int;
    while i < (*ictx).param_list_len {
        match input_get(ictx, i, 0 as libc::c_int, -(1 as libc::c_int)) {
            -1 => {}
            4 => {
                screen_write_mode_set(sctx, 0x2 as libc::c_int);
            }
            34 => {
                screen_write_mode_clear(sctx, 0x10000 as libc::c_int);
            }
            _ => {
                log_debug(
                    b"%s: unknown '%c'\0" as *const u8 as *const libc::c_char,
                    (*::core::mem::transmute::<&[u8; 22], &[libc::c_char; 22]>(
                        b"input_csi_dispatch_sm\0",
                    ))
                    .as_ptr(),
                    (*ictx).ch,
                );
            }
        }
        i = i.wrapping_add(1);
    }
}
unsafe extern "C" fn input_csi_dispatch_sm_private(mut ictx: *mut input_ctx) {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut gc: *mut grid_cell = &mut (*ictx).cell.cell;
    let mut i: u_int = 0;
    i = 0 as libc::c_int as u_int;
    while i < (*ictx).param_list_len {
        match input_get(ictx, i, 0 as libc::c_int, -(1 as libc::c_int)) {
            -1 => {}
            1 => {
                screen_write_mode_set(sctx, 0x4 as libc::c_int);
            }
            3 => {
                screen_write_cursormove(sctx, 0 as libc::c_int, 0 as libc::c_int, 1 as libc::c_int);
                screen_write_clearscreen(sctx, (*ictx).cell.cell.bg as u_int);
            }
            6 => {
                screen_write_mode_set(sctx, 0x2000 as libc::c_int);
                screen_write_cursormove(sctx, 0 as libc::c_int, 0 as libc::c_int, 1 as libc::c_int);
            }
            7 => {
                screen_write_mode_set(sctx, 0x10 as libc::c_int);
            }
            12 => {
                screen_write_mode_set(sctx, 0x80 as libc::c_int);
                screen_write_mode_set(sctx, 0x20000 as libc::c_int);
            }
            25 => {
                screen_write_mode_set(sctx, 0x1 as libc::c_int);
            }
            1000 => {
                screen_write_mode_clear(
                    sctx,
                    0x20 as libc::c_int | 0x40 as libc::c_int | 0x1000 as libc::c_int,
                );
                screen_write_mode_set(sctx, 0x20 as libc::c_int);
            }
            1002 => {
                screen_write_mode_clear(
                    sctx,
                    0x20 as libc::c_int | 0x40 as libc::c_int | 0x1000 as libc::c_int,
                );
                screen_write_mode_set(sctx, 0x40 as libc::c_int);
            }
            1003 => {
                screen_write_mode_clear(
                    sctx,
                    0x20 as libc::c_int | 0x40 as libc::c_int | 0x1000 as libc::c_int,
                );
                screen_write_mode_set(sctx, 0x1000 as libc::c_int);
            }
            1004 => {
                screen_write_mode_set(sctx, 0x800 as libc::c_int);
            }
            1005 => {
                screen_write_mode_set(sctx, 0x100 as libc::c_int);
            }
            1006 => {
                screen_write_mode_set(sctx, 0x200 as libc::c_int);
            }
            47 | 1047 => {
                screen_write_alternateon(sctx, gc, 0 as libc::c_int);
            }
            1049 => {
                screen_write_alternateon(sctx, gc, 1 as libc::c_int);
            }
            2004 => {
                screen_write_mode_set(sctx, 0x400 as libc::c_int);
            }
            _ => {
                log_debug(
                    b"%s: unknown '%c'\0" as *const u8 as *const libc::c_char,
                    (*::core::mem::transmute::<&[u8; 30], &[libc::c_char; 30]>(
                        b"input_csi_dispatch_sm_private\0",
                    ))
                    .as_ptr(),
                    (*ictx).ch,
                );
            }
        }
        i = i.wrapping_add(1);
    }
}
unsafe extern "C" fn input_csi_dispatch_sm_graphics(mut ictx: *mut input_ctx) {}
unsafe extern "C" fn input_csi_dispatch_winops(mut ictx: *mut input_ctx) {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut s: *mut screen = (*sctx).s;
    let mut wp: *mut window_pane = (*ictx).wp;
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut x: u_int = (*(*s).grid).sx;
    let mut y: u_int = (*(*s).grid).sy;
    let mut n: libc::c_int = 0;
    let mut m: libc::c_int = 0;
    if !wp.is_null() {
        w = (*wp).window;
    }
    m = 0 as libc::c_int;
    loop {
        n = input_get(ictx, m as u_int, 0 as libc::c_int, -(1 as libc::c_int));
        if n == -(1 as libc::c_int) {
            break;
        }
        let mut current_block_25: u64;
        match n {
            1 | 2 | 5 | 6 | 7 | 11 | 13 | 20 | 21 | 24 => {
                current_block_25 = 980989089337379490;
            }
            3 | 4 | 8 => {
                m += 1;
                if input_get(ictx, m as u_int, 0 as libc::c_int, -(1 as libc::c_int))
                    == -(1 as libc::c_int)
                {
                    return;
                }
                current_block_25 = 10069753436830853290;
            }
            9 | 10 => {
                current_block_25 = 10069753436830853290;
            }
            14 => {
                if w.is_null() {
                    current_block_25 = 980989089337379490;
                } else {
                    input_reply(
                        ictx,
                        b"\x1B[4;%u;%ut\0" as *const u8 as *const libc::c_char,
                        y.wrapping_mul((*w).ypixel),
                        x.wrapping_mul((*w).xpixel),
                    );
                    current_block_25 = 980989089337379490;
                }
            }
            15 => {
                if w.is_null() {
                    current_block_25 = 980989089337379490;
                } else {
                    input_reply(
                        ictx,
                        b"\x1B[5;%u;%ut\0" as *const u8 as *const libc::c_char,
                        y.wrapping_mul((*w).ypixel),
                        x.wrapping_mul((*w).xpixel),
                    );
                    current_block_25 = 980989089337379490;
                }
            }
            16 => {
                if w.is_null() {
                    current_block_25 = 980989089337379490;
                } else {
                    input_reply(
                        ictx,
                        b"\x1B[6;%u;%ut\0" as *const u8 as *const libc::c_char,
                        (*w).ypixel,
                        (*w).xpixel,
                    );
                    current_block_25 = 980989089337379490;
                }
            }
            18 => {
                input_reply(
                    ictx,
                    b"\x1B[8;%u;%ut\0" as *const u8 as *const libc::c_char,
                    y,
                    x,
                );
                current_block_25 = 980989089337379490;
            }
            19 => {
                input_reply(
                    ictx,
                    b"\x1B[9;%u;%ut\0" as *const u8 as *const libc::c_char,
                    y,
                    x,
                );
                current_block_25 = 980989089337379490;
            }
            22 => {
                m += 1;
                match input_get(ictx, m as u_int, 0 as libc::c_int, -(1 as libc::c_int)) {
                    -1 => return,
                    0 | 2 => {
                        screen_push_title((*sctx).s);
                    }
                    _ => {}
                }
                current_block_25 = 980989089337379490;
            }
            23 => {
                m += 1;
                match input_get(ictx, m as u_int, 0 as libc::c_int, -(1 as libc::c_int)) {
                    -1 => return,
                    0 | 2 => {
                        screen_pop_title((*sctx).s);
                        if !wp.is_null() {
                            notify_pane(
                                b"pane-title-changed\0" as *const u8 as *const libc::c_char,
                                wp,
                            );
                            server_redraw_window_borders(w);
                            server_status_window(w);
                        }
                    }
                    _ => {}
                }
                current_block_25 = 980989089337379490;
            }
            _ => {
                log_debug(
                    b"%s: unknown '%c'\0" as *const u8 as *const libc::c_char,
                    (*::core::mem::transmute::<&[u8; 26], &[libc::c_char; 26]>(
                        b"input_csi_dispatch_winops\0",
                    ))
                    .as_ptr(),
                    (*ictx).ch,
                );
                current_block_25 = 980989089337379490;
            }
        }
        match current_block_25 {
            10069753436830853290 => {
                m += 1;
                if input_get(ictx, m as u_int, 0 as libc::c_int, -(1 as libc::c_int))
                    == -(1 as libc::c_int)
                {
                    return;
                }
            }
            _ => {}
        }
        m += 1;
    }
}
unsafe extern "C" fn input_csi_dispatch_sgr_256_do(
    mut ictx: *mut input_ctx,
    mut fgbg: libc::c_int,
    mut c: libc::c_int,
) -> libc::c_int {
    let mut gc: *mut grid_cell = &mut (*ictx).cell.cell;
    if c == -(1 as libc::c_int) || c > 255 as libc::c_int {
        if fgbg == 38 as libc::c_int {
            (*gc).fg = 8 as libc::c_int;
        } else if fgbg == 48 as libc::c_int {
            (*gc).bg = 8 as libc::c_int;
        }
    } else if fgbg == 38 as libc::c_int {
        (*gc).fg = c | 0x1000000 as libc::c_int;
    } else if fgbg == 48 as libc::c_int {
        (*gc).bg = c | 0x1000000 as libc::c_int;
    } else if fgbg == 58 as libc::c_int {
        (*gc).us = c | 0x1000000 as libc::c_int;
    }
    return 1 as libc::c_int;
}
unsafe extern "C" fn input_csi_dispatch_sgr_256(
    mut ictx: *mut input_ctx,
    mut fgbg: libc::c_int,
    mut i: *mut u_int,
) {
    let mut c: libc::c_int = 0;
    c = input_get(
        ictx,
        (*i).wrapping_add(1 as libc::c_int as libc::c_uint),
        0 as libc::c_int,
        -(1 as libc::c_int),
    );
    if input_csi_dispatch_sgr_256_do(ictx, fgbg, c) != 0 {
        *i = (*i).wrapping_add(1);
    }
}
unsafe extern "C" fn input_csi_dispatch_sgr_rgb_do(
    mut ictx: *mut input_ctx,
    mut fgbg: libc::c_int,
    mut r: libc::c_int,
    mut g: libc::c_int,
    mut b: libc::c_int,
) -> libc::c_int {
    let mut gc: *mut grid_cell = &mut (*ictx).cell.cell;
    if r == -(1 as libc::c_int) || r > 255 as libc::c_int {
        return 0 as libc::c_int;
    }
    if g == -(1 as libc::c_int) || g > 255 as libc::c_int {
        return 0 as libc::c_int;
    }
    if b == -(1 as libc::c_int) || b > 255 as libc::c_int {
        return 0 as libc::c_int;
    }
    if fgbg == 38 as libc::c_int {
        (*gc).fg = colour_join_rgb(r as u_char, g as u_char, b as u_char);
    } else if fgbg == 48 as libc::c_int {
        (*gc).bg = colour_join_rgb(r as u_char, g as u_char, b as u_char);
    } else if fgbg == 58 as libc::c_int {
        (*gc).us = colour_join_rgb(r as u_char, g as u_char, b as u_char);
    }
    return 1 as libc::c_int;
}
unsafe extern "C" fn input_csi_dispatch_sgr_rgb(
    mut ictx: *mut input_ctx,
    mut fgbg: libc::c_int,
    mut i: *mut u_int,
) {
    let mut r: libc::c_int = 0;
    let mut g: libc::c_int = 0;
    let mut b: libc::c_int = 0;
    r = input_get(
        ictx,
        (*i).wrapping_add(1 as libc::c_int as libc::c_uint),
        0 as libc::c_int,
        -(1 as libc::c_int),
    );
    g = input_get(
        ictx,
        (*i).wrapping_add(2 as libc::c_int as libc::c_uint),
        0 as libc::c_int,
        -(1 as libc::c_int),
    );
    b = input_get(
        ictx,
        (*i).wrapping_add(3 as libc::c_int as libc::c_uint),
        0 as libc::c_int,
        -(1 as libc::c_int),
    );
    if input_csi_dispatch_sgr_rgb_do(ictx, fgbg, r, g, b) != 0 {
        *i = (*i as libc::c_uint).wrapping_add(3 as libc::c_int as libc::c_uint) as u_int as u_int;
    }
}
unsafe extern "C" fn input_csi_dispatch_sgr_colon(mut ictx: *mut input_ctx, mut i: u_int) {
    let mut gc: *mut grid_cell = &mut (*ictx).cell.cell;
    let mut s: *mut libc::c_char = (*ictx).param_list[i as usize].c2rust_unnamed.str_0;
    let mut copy: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut ptr: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut out: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut p: [libc::c_int; 8] = [0; 8];
    let mut n: u_int = 0;
    let mut errstr: *const libc::c_char = std::ptr::null::<libc::c_char>();
    n = 0 as libc::c_int as u_int;
    while (n as libc::c_ulong)
        < (::core::mem::size_of::<[libc::c_int; 8]>() as libc::c_ulong)
            .wrapping_div(::core::mem::size_of::<libc::c_int>() as libc::c_ulong)
    {
        p[n as usize] = -(1 as libc::c_int);
        n = n.wrapping_add(1);
    }
    n = 0 as libc::c_int as u_int;
    copy = xstrdup(s);
    ptr = copy;
    loop {
        out = strsep(&mut ptr, b":\0" as *const u8 as *const libc::c_char);
        if out.is_null() {
            break;
        }
        if *out as libc::c_int != '\0' as i32 {
            let fresh8 = n;
            n = n.wrapping_add(1);
            p[fresh8 as usize] = strtonum(
                out,
                0 as libc::c_int as libc::c_longlong,
                2147483647 as libc::c_int as libc::c_longlong,
                &mut errstr,
            ) as libc::c_int;
            if !errstr.is_null()
                || n as libc::c_ulong
                    == (::core::mem::size_of::<[libc::c_int; 8]>() as libc::c_ulong)
                        .wrapping_div(::core::mem::size_of::<libc::c_int>() as libc::c_ulong)
            {
                free(copy as *mut libc::c_void);
                return;
            }
        } else {
            n = n.wrapping_add(1);
            if n as libc::c_ulong
                == (::core::mem::size_of::<[libc::c_int; 8]>() as libc::c_ulong)
                    .wrapping_div(::core::mem::size_of::<libc::c_int>() as libc::c_ulong)
            {
                free(copy as *mut libc::c_void);
                return;
            }
        }
        log_debug(
            b"%s: %u = %d\0" as *const u8 as *const libc::c_char,
            (*::core::mem::transmute::<&[u8; 29], &[libc::c_char; 29]>(
                b"input_csi_dispatch_sgr_colon\0",
            ))
            .as_ptr(),
            n.wrapping_sub(1 as libc::c_int as libc::c_uint),
            p[n.wrapping_sub(1 as libc::c_int as libc::c_uint) as usize],
        );
    }
    free(copy as *mut libc::c_void);
    if n == 0 as libc::c_int as libc::c_uint {
        return;
    }
    if p[0 as libc::c_int as usize] == 4 as libc::c_int {
        if n != 2 as libc::c_int as libc::c_uint {
            return;
        }
        match p[1 as libc::c_int as usize] {
            0 => {
                (*gc).attr = ((*gc).attr as libc::c_int
                    & !(0x4 as libc::c_int
                        | 0x200 as libc::c_int
                        | 0x400 as libc::c_int
                        | 0x800 as libc::c_int
                        | 0x1000 as libc::c_int)) as u_short;
            }
            1 => {
                (*gc).attr = ((*gc).attr as libc::c_int
                    & !(0x4 as libc::c_int
                        | 0x200 as libc::c_int
                        | 0x400 as libc::c_int
                        | 0x800 as libc::c_int
                        | 0x1000 as libc::c_int)) as u_short;
                (*gc).attr = ((*gc).attr as libc::c_int | 0x4 as libc::c_int) as u_short;
            }
            2 => {
                (*gc).attr = ((*gc).attr as libc::c_int
                    & !(0x4 as libc::c_int
                        | 0x200 as libc::c_int
                        | 0x400 as libc::c_int
                        | 0x800 as libc::c_int
                        | 0x1000 as libc::c_int)) as u_short;
                (*gc).attr = ((*gc).attr as libc::c_int | 0x200 as libc::c_int) as u_short;
            }
            3 => {
                (*gc).attr = ((*gc).attr as libc::c_int
                    & !(0x4 as libc::c_int
                        | 0x200 as libc::c_int
                        | 0x400 as libc::c_int
                        | 0x800 as libc::c_int
                        | 0x1000 as libc::c_int)) as u_short;
                (*gc).attr = ((*gc).attr as libc::c_int | 0x400 as libc::c_int) as u_short;
            }
            4 => {
                (*gc).attr = ((*gc).attr as libc::c_int
                    & !(0x4 as libc::c_int
                        | 0x200 as libc::c_int
                        | 0x400 as libc::c_int
                        | 0x800 as libc::c_int
                        | 0x1000 as libc::c_int)) as u_short;
                (*gc).attr = ((*gc).attr as libc::c_int | 0x800 as libc::c_int) as u_short;
            }
            5 => {
                (*gc).attr = ((*gc).attr as libc::c_int
                    & !(0x4 as libc::c_int
                        | 0x200 as libc::c_int
                        | 0x400 as libc::c_int
                        | 0x800 as libc::c_int
                        | 0x1000 as libc::c_int)) as u_short;
                (*gc).attr = ((*gc).attr as libc::c_int | 0x1000 as libc::c_int) as u_short;
            }
            _ => {}
        }
        return;
    }
    if n < 2 as libc::c_int as libc::c_uint
        || p[0 as libc::c_int as usize] != 38 as libc::c_int
            && p[0 as libc::c_int as usize] != 48 as libc::c_int
            && p[0 as libc::c_int as usize] != 58 as libc::c_int
    {
        return;
    }
    match p[1 as libc::c_int as usize] {
        2 => {
            if n >= 3 as libc::c_int as libc::c_uint {
                if n == 5 as libc::c_int as libc::c_uint {
                    i = 2 as libc::c_int as u_int;
                } else {
                    i = 3 as libc::c_int as u_int;
                }
                if n >= i.wrapping_add(3 as libc::c_int as libc::c_uint) {
                    input_csi_dispatch_sgr_rgb_do(
                        ictx,
                        p[0 as libc::c_int as usize],
                        p[i as usize],
                        p[i.wrapping_add(1 as libc::c_int as libc::c_uint) as usize],
                        p[i.wrapping_add(2 as libc::c_int as libc::c_uint) as usize],
                    );
                }
            }
        }
        5 => {
            if n >= 3 as libc::c_int as libc::c_uint {
                input_csi_dispatch_sgr_256_do(
                    ictx,
                    p[0 as libc::c_int as usize],
                    p[2 as libc::c_int as usize],
                );
            }
        }
        _ => {}
    };
}
unsafe extern "C" fn input_csi_dispatch_sgr(mut ictx: *mut input_ctx) {
    let mut gc: *mut grid_cell = &mut (*ictx).cell.cell;
    let mut i: u_int = 0;
    let mut link: u_int = 0;
    let mut n: libc::c_int = 0;
    if (*ictx).param_list_len == 0 as libc::c_int as libc::c_uint {
        memcpy(
            gc as *mut libc::c_void,
            &grid_default_cell as *const grid_cell as *const libc::c_void,
            ::core::mem::size_of::<grid_cell>() as libc::c_ulong,
        );
        return;
    }
    i = 0 as libc::c_int as u_int;
    while i < (*ictx).param_list_len {
        if (*ictx).param_list[i as usize].type_0 as libc::c_uint
            == INPUT_STRING as libc::c_int as libc::c_uint
        {
            input_csi_dispatch_sgr_colon(ictx, i);
        } else {
            n = input_get(ictx, i, 0 as libc::c_int, 0 as libc::c_int);
            if n != -(1 as libc::c_int) {
                if n == 38 as libc::c_int || n == 48 as libc::c_int || n == 58 as libc::c_int {
                    i = i.wrapping_add(1);
                    match input_get(ictx, i, 0 as libc::c_int, -(1 as libc::c_int)) {
                        2 => {
                            input_csi_dispatch_sgr_rgb(ictx, n, &mut i);
                        }
                        5 => {
                            input_csi_dispatch_sgr_256(ictx, n, &mut i);
                        }
                        _ => {}
                    }
                } else {
                    match n {
                        0 => {
                            link = (*gc).link;
                            memcpy(
                                gc as *mut libc::c_void,
                                &grid_default_cell as *const grid_cell as *const libc::c_void,
                                ::core::mem::size_of::<grid_cell>() as libc::c_ulong,
                            );
                            (*gc).link = link;
                        }
                        1 => {
                            (*gc).attr =
                                ((*gc).attr as libc::c_int | 0x1 as libc::c_int) as u_short;
                        }
                        2 => {
                            (*gc).attr =
                                ((*gc).attr as libc::c_int | 0x2 as libc::c_int) as u_short;
                        }
                        3 => {
                            (*gc).attr =
                                ((*gc).attr as libc::c_int | 0x40 as libc::c_int) as u_short;
                        }
                        4 => {
                            (*gc).attr = ((*gc).attr as libc::c_int
                                & !(0x4 as libc::c_int
                                    | 0x200 as libc::c_int
                                    | 0x400 as libc::c_int
                                    | 0x800 as libc::c_int
                                    | 0x1000 as libc::c_int))
                                as u_short;
                            (*gc).attr =
                                ((*gc).attr as libc::c_int | 0x4 as libc::c_int) as u_short;
                        }
                        5 | 6 => {
                            (*gc).attr =
                                ((*gc).attr as libc::c_int | 0x8 as libc::c_int) as u_short;
                        }
                        7 => {
                            (*gc).attr =
                                ((*gc).attr as libc::c_int | 0x10 as libc::c_int) as u_short;
                        }
                        8 => {
                            (*gc).attr =
                                ((*gc).attr as libc::c_int | 0x20 as libc::c_int) as u_short;
                        }
                        9 => {
                            (*gc).attr =
                                ((*gc).attr as libc::c_int | 0x100 as libc::c_int) as u_short;
                        }
                        21 => {
                            (*gc).attr = ((*gc).attr as libc::c_int
                                & !(0x4 as libc::c_int
                                    | 0x200 as libc::c_int
                                    | 0x400 as libc::c_int
                                    | 0x800 as libc::c_int
                                    | 0x1000 as libc::c_int))
                                as u_short;
                            (*gc).attr =
                                ((*gc).attr as libc::c_int | 0x200 as libc::c_int) as u_short;
                        }
                        22 => {
                            (*gc).attr = ((*gc).attr as libc::c_int
                                & !(0x1 as libc::c_int | 0x2 as libc::c_int))
                                as u_short;
                        }
                        23 => {
                            (*gc).attr =
                                ((*gc).attr as libc::c_int & !(0x40 as libc::c_int)) as u_short;
                        }
                        24 => {
                            (*gc).attr = ((*gc).attr as libc::c_int
                                & !(0x4 as libc::c_int
                                    | 0x200 as libc::c_int
                                    | 0x400 as libc::c_int
                                    | 0x800 as libc::c_int
                                    | 0x1000 as libc::c_int))
                                as u_short;
                        }
                        25 => {
                            (*gc).attr =
                                ((*gc).attr as libc::c_int & !(0x8 as libc::c_int)) as u_short;
                        }
                        27 => {
                            (*gc).attr =
                                ((*gc).attr as libc::c_int & !(0x10 as libc::c_int)) as u_short;
                        }
                        28 => {
                            (*gc).attr =
                                ((*gc).attr as libc::c_int & !(0x20 as libc::c_int)) as u_short;
                        }
                        29 => {
                            (*gc).attr =
                                ((*gc).attr as libc::c_int & !(0x100 as libc::c_int)) as u_short;
                        }
                        30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 => {
                            (*gc).fg = n - 30 as libc::c_int;
                        }
                        39 => {
                            (*gc).fg = 8 as libc::c_int;
                        }
                        40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 => {
                            (*gc).bg = n - 40 as libc::c_int;
                        }
                        49 => {
                            (*gc).bg = 8 as libc::c_int;
                        }
                        53 => {
                            (*gc).attr =
                                ((*gc).attr as libc::c_int | 0x2000 as libc::c_int) as u_short;
                        }
                        55 => {
                            (*gc).attr =
                                ((*gc).attr as libc::c_int & !(0x2000 as libc::c_int)) as u_short;
                        }
                        59 => {
                            (*gc).us = 8 as libc::c_int;
                        }
                        90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 => {
                            (*gc).fg = n;
                        }
                        100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 => {
                            (*gc).bg = n - 10 as libc::c_int;
                        }
                        _ => {}
                    }
                }
            }
        }
        i = i.wrapping_add(1);
    }
}
unsafe extern "C" fn input_end_bel(mut ictx: *mut input_ctx) -> libc::c_int {
    log_debug(
        b"%s\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>(b"input_end_bel\0")).as_ptr(),
    );
    (*ictx).input_end = INPUT_END_BEL;
    return 0 as libc::c_int;
}
unsafe extern "C" fn input_enter_dcs(mut ictx: *mut input_ctx) {
    log_debug(
        b"%s\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"input_enter_dcs\0")).as_ptr(),
    );
    input_clear(ictx);
    input_start_timer(ictx);
    (*ictx).flags &= !(0x2 as libc::c_int);
}
unsafe extern "C" fn input_dcs_dispatch(mut ictx: *mut input_ctx) -> libc::c_int {
    let mut wp: *mut window_pane = (*ictx).wp;
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut buf: *mut u_char = (*ictx).input_buf;
    let mut len: size_t = (*ictx).input_len;
    let prefix: [libc::c_char; 6] =
        *::core::mem::transmute::<&[u8; 6], &[libc::c_char; 6]>(b"tmux;\0");
    let prefixlen: u_int = (::core::mem::size_of::<[libc::c_char; 6]>() as libc::c_ulong)
        .wrapping_sub(1 as libc::c_int as libc::c_ulong) as u_int;
    let mut allow_passthrough: libc::c_longlong = 0 as libc::c_int as libc::c_longlong;
    if wp.is_null() {
        return 0 as libc::c_int;
    }
    if (*ictx).flags & 0x1 as libc::c_int != 0 {
        log_debug(
            b"%s: %zu bytes (discard)\0" as *const u8 as *const libc::c_char,
            (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(b"input_dcs_dispatch\0"))
                .as_ptr(),
            len,
        );
        return 0 as libc::c_int;
    }
    allow_passthrough = options_get_number(
        (*wp).options,
        b"allow-passthrough\0" as *const u8 as *const libc::c_char,
    );
    if allow_passthrough == 0 {
        return 0 as libc::c_int;
    }
    log_debug(
        b"%s: \"%s\"\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(b"input_dcs_dispatch\0"))
            .as_ptr(),
        buf,
    );
    if len >= prefixlen as libc::c_ulong
        && strncmp(
            buf as *const libc::c_char,
            prefix.as_ptr(),
            prefixlen as libc::c_ulong,
        ) == 0 as libc::c_int
    {
        screen_write_rawstring(
            sctx,
            buf.offset(prefixlen as isize),
            len.wrapping_sub(prefixlen as libc::c_ulong) as u_int,
            (allow_passthrough == 2 as libc::c_int as libc::c_longlong) as libc::c_int,
        );
    }
    return 0 as libc::c_int;
}
unsafe extern "C" fn input_enter_osc(mut ictx: *mut input_ctx) {
    log_debug(
        b"%s\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"input_enter_osc\0")).as_ptr(),
    );
    input_clear(ictx);
    input_start_timer(ictx);
    (*ictx).flags &= !(0x2 as libc::c_int);
}
unsafe extern "C" fn input_exit_osc(mut ictx: *mut input_ctx) {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut wp: *mut window_pane = (*ictx).wp;
    let mut p: *mut u_char = (*ictx).input_buf;
    let mut option: u_int = 0;
    if (*ictx).flags & 0x1 as libc::c_int != 0 {
        return;
    }
    if (*ictx).input_len < 1 as libc::c_int as libc::c_ulong
        || (*p as libc::c_int) < '0' as i32
        || *p as libc::c_int > '9' as i32
    {
        return;
    }
    log_debug(
        b"%s: \"%s\" (end %s)\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"input_exit_osc\0")).as_ptr(),
        p,
        if (*ictx).input_end as libc::c_uint == INPUT_END_ST as libc::c_int as libc::c_uint {
            b"ST\0" as *const u8 as *const libc::c_char
        } else {
            b"BEL\0" as *const u8 as *const libc::c_char
        },
    );
    option = 0 as libc::c_int as u_int;
    while *p as libc::c_int >= '0' as i32 && *p as libc::c_int <= '9' as i32 {
        let fresh9 = p;
        p = p.offset(1);
        option = option
            .wrapping_mul(10 as libc::c_int as libc::c_uint)
            .wrapping_add(*fresh9 as libc::c_uint)
            .wrapping_sub('0' as i32 as libc::c_uint);
    }
    if *p as libc::c_int != ';' as i32 && *p as libc::c_int != '\0' as i32 {
        return;
    }
    if *p as libc::c_int == ';' as i32 {
        p = p.offset(1);
    }
    match option {
        0 | 2 => {
            if !wp.is_null()
                && options_get_number(
                    (*wp).options,
                    b"allow-set-title\0" as *const u8 as *const libc::c_char,
                ) != 0
                && screen_set_title((*sctx).s, p as *const libc::c_char) != 0
            {
                notify_pane(
                    b"pane-title-changed\0" as *const u8 as *const libc::c_char,
                    wp,
                );
                server_redraw_window_borders((*wp).window);
                server_status_window((*wp).window);
            }
        }
        4 => {
            input_osc_4(ictx, p as *const libc::c_char);
        }
        7 => {
            if utf8_isvalid(p as *const libc::c_char) != 0 {
                screen_set_path((*sctx).s, p as *const libc::c_char);
                if !wp.is_null() {
                    server_redraw_window_borders((*wp).window);
                    server_status_window((*wp).window);
                }
            }
        }
        8 => {
            input_osc_8(ictx, p as *const libc::c_char);
        }
        10 => {
            input_osc_10(ictx, p as *const libc::c_char);
        }
        11 => {
            input_osc_11(ictx, p as *const libc::c_char);
        }
        12 => {
            input_osc_12(ictx, p as *const libc::c_char);
        }
        52 => {
            input_osc_52(ictx, p as *const libc::c_char);
        }
        104 => {
            input_osc_104(ictx, p as *const libc::c_char);
        }
        110 => {
            input_osc_110(ictx, p as *const libc::c_char);
        }
        111 => {
            input_osc_111(ictx, p as *const libc::c_char);
        }
        112 => {
            input_osc_112(ictx, p as *const libc::c_char);
        }
        133 => {
            input_osc_133(ictx, p as *const libc::c_char);
        }
        _ => {
            log_debug(
                b"%s: unknown '%u'\0" as *const u8 as *const libc::c_char,
                (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"input_exit_osc\0"))
                    .as_ptr(),
                option,
            );
        }
    };
}
unsafe extern "C" fn input_enter_apc(mut ictx: *mut input_ctx) {
    log_debug(
        b"%s\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"input_enter_apc\0")).as_ptr(),
    );
    input_clear(ictx);
    input_start_timer(ictx);
    (*ictx).flags &= !(0x2 as libc::c_int);
}
unsafe extern "C" fn input_exit_apc(mut ictx: *mut input_ctx) {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut wp: *mut window_pane = (*ictx).wp;
    if (*ictx).flags & 0x1 as libc::c_int != 0 {
        return;
    }
    log_debug(
        b"%s: \"%s\"\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"input_exit_apc\0")).as_ptr(),
        (*ictx).input_buf,
    );
    if screen_set_title((*sctx).s, (*ictx).input_buf as *const libc::c_char) != 0 && !wp.is_null() {
        notify_pane(
            b"pane-title-changed\0" as *const u8 as *const libc::c_char,
            wp,
        );
        server_redraw_window_borders((*wp).window);
        server_status_window((*wp).window);
    }
}
unsafe extern "C" fn input_enter_rename(mut ictx: *mut input_ctx) {
    log_debug(
        b"%s\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(b"input_enter_rename\0"))
            .as_ptr(),
    );
    input_clear(ictx);
    input_start_timer(ictx);
    (*ictx).flags &= !(0x2 as libc::c_int);
}
unsafe extern "C" fn input_exit_rename(mut ictx: *mut input_ctx) {
    let mut wp: *mut window_pane = (*ictx).wp;
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut o: *mut options_entry = std::ptr::null_mut::<options_entry>();
    if wp.is_null() {
        return;
    }
    if (*ictx).flags & 0x1 as libc::c_int != 0 {
        return;
    }
    if options_get_number(
        (*(*ictx).wp).options,
        b"allow-rename\0" as *const u8 as *const libc::c_char,
    ) == 0
    {
        return;
    }
    log_debug(
        b"%s: \"%s\"\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 18], &[libc::c_char; 18]>(b"input_exit_rename\0"))
            .as_ptr(),
        (*ictx).input_buf,
    );
    if utf8_isvalid((*ictx).input_buf as *const libc::c_char) == 0 {
        return;
    }
    w = (*wp).window;
    if (*ictx).input_len == 0 as libc::c_int as libc::c_ulong {
        o = options_get_only(
            (*w).options,
            b"automatic-rename\0" as *const u8 as *const libc::c_char,
        );
        if !o.is_null() {
            options_remove_or_default(
                o,
                -(1 as libc::c_int),
                std::ptr::null_mut::<*mut libc::c_char>(),
            );
        }
        if options_get_number(
            (*w).options,
            b"automatic-rename\0" as *const u8 as *const libc::c_char,
        ) == 0
        {
            window_set_name(w, b"\0" as *const u8 as *const libc::c_char);
        }
    } else {
        options_set_number(
            (*w).options,
            b"automatic-rename\0" as *const u8 as *const libc::c_char,
            0 as libc::c_int as libc::c_longlong,
        );
        window_set_name(w, (*ictx).input_buf as *const libc::c_char);
    }
    server_redraw_window_borders(w);
    server_status_window(w);
}
unsafe extern "C" fn input_top_bit_set(mut ictx: *mut input_ctx) -> libc::c_int {
    let mut sctx: *mut screen_write_ctx = &mut (*ictx).ctx;
    let mut ud: *mut utf8_data = &mut (*ictx).utf8data;
    (*ictx).flags &= !(0x2 as libc::c_int);
    if (*ictx).utf8started == 0 {
        if utf8_open(ud, (*ictx).ch as u_char) as libc::c_uint
            != UTF8_MORE as libc::c_int as libc::c_uint
        {
            return 0 as libc::c_int;
        }
        (*ictx).utf8started = 1 as libc::c_int;
        return 0 as libc::c_int;
    }
    match utf8_append(ud, (*ictx).ch as u_char) as libc::c_uint {
        0 => return 0 as libc::c_int,
        2 => {
            (*ictx).utf8started = 0 as libc::c_int;
            return 0 as libc::c_int;
        }
        1 | _ => {}
    }
    (*ictx).utf8started = 0 as libc::c_int;
    log_debug(
        b"%s %hhu '%*s' (width %hhu)\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 18], &[libc::c_char; 18]>(b"input_top_bit_set\0"))
            .as_ptr(),
        (*ud).size as libc::c_int,
        (*ud).size as libc::c_int,
        ((*ud).data).as_mut_ptr(),
        (*ud).width as libc::c_int,
    );
    utf8_copy(&mut (*ictx).cell.cell.data, ud);
    screen_write_collect_add(sctx, &mut (*ictx).cell.cell);
    utf8_copy(&mut (*ictx).last, &mut (*ictx).cell.cell.data);
    (*ictx).flags |= 0x2 as libc::c_int;
    return 0 as libc::c_int;
}
unsafe extern "C" fn input_osc_colour_reply(
    mut ictx: *mut input_ctx,
    mut n: u_int,
    mut c: libc::c_int,
) {
    let mut r: u_char = 0;
    let mut g: u_char = 0;
    let mut b: u_char = 0;
    let mut end: *const libc::c_char = std::ptr::null::<libc::c_char>();
    if c != -(1 as libc::c_int) {
        c = colour_force_rgb(c);
    }
    if c == -(1 as libc::c_int) {
        return;
    }
    colour_split_rgb(c, &mut r, &mut g, &mut b);
    if (*ictx).input_end as libc::c_uint == INPUT_END_BEL as libc::c_int as libc::c_uint {
        end = b"\x07\0" as *const u8 as *const libc::c_char;
    } else {
        end = b"\x1B\\\0" as *const u8 as *const libc::c_char;
    }
    input_reply(
        ictx,
        b"\x1B]%u;rgb:%02hhx%02hhx/%02hhx%02hhx/%02hhx%02hhx%s\0" as *const u8
            as *const libc::c_char,
        n,
        r as libc::c_int,
        r as libc::c_int,
        g as libc::c_int,
        g as libc::c_int,
        b as libc::c_int,
        b as libc::c_int,
        end,
    );
}
unsafe extern "C" fn input_osc_4(mut ictx: *mut input_ctx, mut p: *const libc::c_char) {
    let mut copy: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut s: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut next: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut idx: libc::c_long = 0;
    let mut c: libc::c_int = 0;
    let mut bad: libc::c_int = 0 as libc::c_int;
    let mut redraw: libc::c_int = 0 as libc::c_int;
    s = xstrdup(p);
    copy = s;
    while !s.is_null() && *s as libc::c_int != '\0' as i32 {
        idx = strtol(s, &mut next, 10 as libc::c_int);
        let fresh10 = next;
        next = next.offset(1);
        if *fresh10 as libc::c_int != ';' as i32 {
            bad = 1 as libc::c_int;
            break;
        } else if idx < 0 as libc::c_int as libc::c_long
            || idx >= 256 as libc::c_int as libc::c_long
        {
            bad = 1 as libc::c_int;
            break;
        } else {
            s = strsep(&mut next, b";\0" as *const u8 as *const libc::c_char);
            if strcmp(s, b"?\0" as *const u8 as *const libc::c_char) == 0 as libc::c_int {
                c = colour_palette_get((*ictx).palette, idx as libc::c_int);
                if c != -(1 as libc::c_int) {
                    input_osc_colour_reply(ictx, 4 as libc::c_int as u_int, c);
                }
            } else {
                c = colour_parseX11(s);
                if c == -(1 as libc::c_int) {
                    s = next;
                } else {
                    if colour_palette_set((*ictx).palette, idx as libc::c_int, c) != 0 {
                        redraw = 1 as libc::c_int;
                    }
                    s = next;
                }
            }
        }
    }
    if bad != 0 {
        log_debug(b"bad OSC 4: %s\0" as *const u8 as *const libc::c_char, p);
    }
    if redraw != 0 {
        screen_write_fullredraw(&mut (*ictx).ctx);
    }
    free(copy as *mut libc::c_void);
}
unsafe extern "C" fn input_osc_8(mut ictx: *mut input_ctx, mut p: *const libc::c_char) {
    let mut current_block: u64;
    let mut hl: *mut hyperlinks = (*(*ictx).ctx.s).hyperlinks;
    let mut gc: *mut grid_cell = &mut (*ictx).cell.cell;
    let mut start: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut end: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut uri: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut id: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    start = p;
    loop {
        end = strpbrk(start, b":;\0" as *const u8 as *const libc::c_char);
        if end.is_null() {
            current_block = 10886091980245723256;
            break;
        }
        if end.offset_from(start) as libc::c_long >= 4 as libc::c_int as libc::c_long
            && strncmp(
                start,
                b"id=\0" as *const u8 as *const libc::c_char,
                3 as libc::c_int as libc::c_ulong,
            ) == 0 as libc::c_int
        {
            if !id.is_null() {
                current_block = 11065970277985398121;
                break;
            }
            id = xstrndup(
                start.offset(3 as libc::c_int as isize),
                (end.offset_from(start) as libc::c_long - 3 as libc::c_int as libc::c_long)
                    as size_t,
            );
        }
        if *end as libc::c_int == ';' as i32 {
            current_block = 10886091980245723256;
            break;
        }
        start = end.offset(1 as libc::c_int as isize);
    }
    match current_block {
        10886091980245723256 => {
            if !(end.is_null() || *end as libc::c_int != ';' as i32) {
                uri = end.offset(1 as libc::c_int as isize);
                if *uri as libc::c_int == '\0' as i32 {
                    (*gc).link = 0 as libc::c_int as u_int;
                    free(id as *mut libc::c_void);
                    return;
                }
                (*gc).link = hyperlinks_put(hl, uri, id);
                if id.is_null() {
                    log_debug(
                        b"hyperlink (anonymous) %s = %u\0" as *const u8 as *const libc::c_char,
                        uri,
                        (*gc).link,
                    );
                } else {
                    log_debug(
                        b"hyperlink (id=%s) %s = %u\0" as *const u8 as *const libc::c_char,
                        id,
                        uri,
                        (*gc).link,
                    );
                }
                free(id as *mut libc::c_void);
                return;
            }
        }
        _ => {}
    }
    log_debug(b"bad OSC 8 %s\0" as *const u8 as *const libc::c_char, p);
    free(id as *mut libc::c_void);
}
unsafe extern "C" fn input_get_fg_client(mut wp: *mut window_pane) -> libc::c_int {
    let mut w: *mut window = (*wp).window;
    let mut loop_0: *mut client = std::ptr::null_mut::<client>();
    loop_0 = clients.tqh_first;
    while !loop_0.is_null() {
        if (*loop_0).flags
            & (0x200 as libc::c_int | 0x40 as libc::c_int | 0x4 as libc::c_int) as libc::c_ulong
            == 0
        {
            if !(((*loop_0).session).is_null() || session_has((*loop_0).session, w) == 0) {
                if (*loop_0).tty.fg != -(1 as libc::c_int) {
                    return (*loop_0).tty.fg;
                }
            }
        }
        loop_0 = (*loop_0).entry.tqe_next;
    }
    return -(1 as libc::c_int);
}
unsafe extern "C" fn input_get_bg_client(mut wp: *mut window_pane) -> libc::c_int {
    let mut w: *mut window = (*wp).window;
    let mut loop_0: *mut client = std::ptr::null_mut::<client>();
    loop_0 = clients.tqh_first;
    while !loop_0.is_null() {
        if (*loop_0).flags
            & (0x200 as libc::c_int | 0x40 as libc::c_int | 0x4 as libc::c_int) as libc::c_ulong
            == 0
        {
            if !(((*loop_0).session).is_null() || session_has((*loop_0).session, w) == 0) {
                if (*loop_0).tty.bg != -(1 as libc::c_int) {
                    return (*loop_0).tty.bg;
                }
            }
        }
        loop_0 = (*loop_0).entry.tqe_next;
    }
    return -(1 as libc::c_int);
}
unsafe extern "C" fn input_get_bg_control_client(mut wp: *mut window_pane) -> libc::c_int {
    let mut c: *mut client = std::ptr::null_mut::<client>();
    if (*wp).control_bg == -(1 as libc::c_int) {
        return -(1 as libc::c_int);
    }
    c = clients.tqh_first;
    while !c.is_null() {
        if (*c).flags & 0x2000 as libc::c_int as libc::c_ulong != 0 {
            return (*wp).control_bg;
        }
        c = (*c).entry.tqe_next;
    }
    return -(1 as libc::c_int);
}
unsafe extern "C" fn input_get_fg_control_client(mut wp: *mut window_pane) -> libc::c_int {
    let mut c: *mut client = std::ptr::null_mut::<client>();
    if (*wp).control_fg == -(1 as libc::c_int) {
        return -(1 as libc::c_int);
    }
    c = clients.tqh_first;
    while !c.is_null() {
        if (*c).flags & 0x2000 as libc::c_int as libc::c_ulong != 0 {
            return (*wp).control_fg;
        }
        c = (*c).entry.tqe_next;
    }
    return -(1 as libc::c_int);
}
unsafe extern "C" fn input_osc_10(mut ictx: *mut input_ctx, mut p: *const libc::c_char) {
    let mut wp: *mut window_pane = (*ictx).wp;
    let mut defaults: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    let mut c: libc::c_int = 0;
    if strcmp(p, b"?\0" as *const u8 as *const libc::c_char) == 0 as libc::c_int {
        if wp.is_null() {
            return;
        }
        c = input_get_fg_control_client(wp);
        if c == -(1 as libc::c_int) {
            tty_default_colours(&mut defaults, wp);
            if defaults.fg == 8 as libc::c_int || defaults.fg == 9 as libc::c_int {
                c = input_get_fg_client(wp);
            } else {
                c = defaults.fg;
            }
        }
        input_osc_colour_reply(ictx, 10 as libc::c_int as u_int, c);
        return;
    }
    c = colour_parseX11(p);
    if c == -(1 as libc::c_int) {
        log_debug(b"bad OSC 10: %s\0" as *const u8 as *const libc::c_char, p);
        return;
    }
    if !((*ictx).palette).is_null() {
        (*(*ictx).palette).fg = c;
        if !wp.is_null() {
            (*wp).flags |= 0x1000 as libc::c_int;
        }
        screen_write_fullredraw(&mut (*ictx).ctx);
    }
}
unsafe extern "C" fn input_osc_110(mut ictx: *mut input_ctx, mut p: *const libc::c_char) {
    let mut wp: *mut window_pane = (*ictx).wp;
    if *p as libc::c_int != '\0' as i32 {
        return;
    }
    if !((*ictx).palette).is_null() {
        (*(*ictx).palette).fg = 8 as libc::c_int;
        if !wp.is_null() {
            (*wp).flags |= 0x1000 as libc::c_int;
        }
        screen_write_fullredraw(&mut (*ictx).ctx);
    }
}
unsafe extern "C" fn input_osc_11(mut ictx: *mut input_ctx, mut p: *const libc::c_char) {
    let mut wp: *mut window_pane = (*ictx).wp;
    let mut defaults: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    let mut c: libc::c_int = 0;
    if strcmp(p, b"?\0" as *const u8 as *const libc::c_char) == 0 as libc::c_int {
        if wp.is_null() {
            return;
        }
        c = input_get_bg_control_client(wp);
        if c == -(1 as libc::c_int) {
            tty_default_colours(&mut defaults, wp);
            if defaults.bg == 8 as libc::c_int || defaults.bg == 9 as libc::c_int {
                c = input_get_bg_client(wp);
            } else {
                c = defaults.bg;
            }
        }
        input_osc_colour_reply(ictx, 11 as libc::c_int as u_int, c);
        return;
    }
    c = colour_parseX11(p);
    if c == -(1 as libc::c_int) {
        log_debug(b"bad OSC 11: %s\0" as *const u8 as *const libc::c_char, p);
        return;
    }
    if !((*ictx).palette).is_null() {
        (*(*ictx).palette).bg = c;
        if !wp.is_null() {
            (*wp).flags |= 0x1000 as libc::c_int;
        }
        screen_write_fullredraw(&mut (*ictx).ctx);
    }
}
unsafe extern "C" fn input_osc_111(mut ictx: *mut input_ctx, mut p: *const libc::c_char) {
    let mut wp: *mut window_pane = (*ictx).wp;
    if *p as libc::c_int != '\0' as i32 {
        return;
    }
    if !((*ictx).palette).is_null() {
        (*(*ictx).palette).bg = 8 as libc::c_int;
        if !wp.is_null() {
            (*wp).flags |= 0x1000 as libc::c_int;
        }
        screen_write_fullredraw(&mut (*ictx).ctx);
    }
}
unsafe extern "C" fn input_osc_12(mut ictx: *mut input_ctx, mut p: *const libc::c_char) {
    let mut wp: *mut window_pane = (*ictx).wp;
    let mut c: libc::c_int = 0;
    if strcmp(p, b"?\0" as *const u8 as *const libc::c_char) == 0 as libc::c_int {
        if !wp.is_null() {
            c = (*(*ictx).ctx.s).ccolour;
            if c == -(1 as libc::c_int) {
                c = (*(*ictx).ctx.s).default_ccolour;
            }
            input_osc_colour_reply(ictx, 12 as libc::c_int as u_int, c);
        }
        return;
    }
    c = colour_parseX11(p);
    if c == -(1 as libc::c_int) {
        log_debug(b"bad OSC 12: %s\0" as *const u8 as *const libc::c_char, p);
        return;
    }
    screen_set_cursor_colour((*ictx).ctx.s, c);
}
unsafe extern "C" fn input_osc_112(mut ictx: *mut input_ctx, mut p: *const libc::c_char) {
    if *p as libc::c_int == '\0' as i32 {
        screen_set_cursor_colour((*ictx).ctx.s, -(1 as libc::c_int));
    }
}
unsafe extern "C" fn input_osc_133(mut ictx: *mut input_ctx, mut p: *const libc::c_char) {
    let mut gd: *mut grid = (*(*ictx).ctx.s).grid;
    let mut line: u_int = ((*(*ictx).ctx.s).cy).wrapping_add((*gd).hsize);
    let mut gl: *mut grid_line = std::ptr::null_mut::<grid_line>();
    if line
        > ((*gd).hsize)
            .wrapping_add((*gd).sy)
            .wrapping_sub(1 as libc::c_int as libc::c_uint)
    {
        return;
    }
    gl = grid_get_line(gd, line);
    match *p as libc::c_int {
        65 => {
            (*gl).flags |= 0x8 as libc::c_int;
        }
        67 => {
            (*gl).flags |= 0x10 as libc::c_int;
        }
        _ => {}
    };
}
unsafe extern "C" fn input_osc_52(mut ictx: *mut input_ctx, mut p: *const libc::c_char) {
    let mut wp: *mut window_pane = (*ictx).wp;
    let mut end: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut buf: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut len: size_t = 0 as libc::c_int as size_t;
    let mut out: *mut u_char = std::ptr::null_mut::<u_char>();
    let mut outlen: libc::c_int = 0;
    let mut state: libc::c_int = 0;
    let mut ctx: screen_write_ctx = screen_write_ctx {
        wp: std::ptr::null_mut::<window_pane>(),
        s: std::ptr::null_mut::<screen>(),
        flags: 0,
        init_ctx_cb: None,
        arg: std::ptr::null_mut::<libc::c_void>(),
        item: std::ptr::null_mut::<screen_write_citem>(),
        scrolled: 0,
        bg: 0,
    };
    let mut pb: *mut paste_buffer = std::ptr::null_mut::<paste_buffer>();
    let mut allow: *const libc::c_char = b"cpqs01234567\0" as *const u8 as *const libc::c_char;
    let mut flags: [libc::c_char; 13] = *::core::mem::transmute::<&[u8; 13], &mut [libc::c_char; 13]>(
        b"\0\0\0\0\0\0\0\0\0\0\0\0\0",
    );
    let mut i: u_int = 0;
    let mut j: u_int = 0 as libc::c_int as u_int;
    if wp.is_null() {
        return;
    }
    state = options_get_number(
        global_options,
        b"set-clipboard\0" as *const u8 as *const libc::c_char,
    ) as libc::c_int;
    if state != 2 as libc::c_int {
        return;
    }
    end = strchr(p, ';' as i32);
    if end.is_null() {
        return;
    }
    end = end.offset(1);
    if *end as libc::c_int == '\0' as i32 {
        return;
    }
    log_debug(
        b"%s: %s\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 13], &[libc::c_char; 13]>(b"input_osc_52\0")).as_ptr(),
        end,
    );
    i = 0 as libc::c_int as u_int;
    while p.offset(i as isize) != end as *const libc::c_char {
        if !(strchr(allow, *p.offset(i as isize) as libc::c_int)).is_null()
            && (strchr(flags.as_mut_ptr(), *p.offset(i as isize) as libc::c_int)).is_null()
        {
            let fresh11 = j;
            j = j.wrapping_add(1);
            flags[fresh11 as usize] = *p.offset(i as isize);
        }
        i = i.wrapping_add(1);
    }
    log_debug(
        b"%s: %.*s %s\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 13], &[libc::c_char; 13]>(b"input_osc_52\0")).as_ptr(),
        (end.offset_from(p) as libc::c_long - 1 as libc::c_int as libc::c_long) as libc::c_int,
        p,
        flags.as_mut_ptr(),
    );
    if strcmp(end, b"?\0" as *const u8 as *const libc::c_char) == 0 as libc::c_int {
        pb = paste_get_top(std::ptr::null_mut::<*const libc::c_char>());
        if !pb.is_null() {
            buf = paste_buffer_data(pb, &mut len);
        }
        if (*ictx).input_end as libc::c_uint == INPUT_END_BEL as libc::c_int as libc::c_uint {
            input_reply_clipboard(
                (*ictx).event,
                buf,
                len,
                b"\x07\0" as *const u8 as *const libc::c_char,
            );
        } else {
            input_reply_clipboard(
                (*ictx).event,
                buf,
                len,
                b"\x1B\\\0" as *const u8 as *const libc::c_char,
            );
        }
        return;
    }
    len = (strlen(end))
        .wrapping_div(4 as libc::c_int as libc::c_ulong)
        .wrapping_mul(3 as libc::c_int as libc::c_ulong);
    if len == 0 as libc::c_int as libc::c_ulong {
        return;
    }
    out = xmalloc(len) as *mut u_char;
    outlen = __b64_pton(end, out, len);
    if outlen == -(1 as libc::c_int) {
        free(out as *mut libc::c_void);
        return;
    }
    screen_write_start_pane(&mut ctx, wp, std::ptr::null_mut::<screen>());
    screen_write_setselection(&mut ctx, flags.as_mut_ptr(), out, outlen as u_int);
    screen_write_stop(&mut ctx);
    notify_pane(
        b"pane-set-clipboard\0" as *const u8 as *const libc::c_char,
        wp,
    );
    paste_add(
        std::ptr::null::<libc::c_char>(),
        out as *mut libc::c_char,
        outlen as size_t,
    );
}
unsafe extern "C" fn input_osc_104(mut ictx: *mut input_ctx, mut p: *const libc::c_char) {
    let mut copy: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut s: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut idx: libc::c_long = 0;
    let mut bad: libc::c_int = 0 as libc::c_int;
    let mut redraw: libc::c_int = 0 as libc::c_int;
    if *p as libc::c_int == '\0' as i32 {
        colour_palette_clear((*ictx).palette);
        screen_write_fullredraw(&mut (*ictx).ctx);
        return;
    }
    s = xstrdup(p);
    copy = s;
    while *s as libc::c_int != '\0' as i32 {
        idx = strtol(s, &mut s, 10 as libc::c_int);
        if *s as libc::c_int != '\0' as i32 && *s as libc::c_int != ';' as i32 {
            bad = 1 as libc::c_int;
            break;
        } else if idx < 0 as libc::c_int as libc::c_long
            || idx >= 256 as libc::c_int as libc::c_long
        {
            bad = 1 as libc::c_int;
            break;
        } else {
            if colour_palette_set((*ictx).palette, idx as libc::c_int, -(1 as libc::c_int)) != 0 {
                redraw = 1 as libc::c_int;
            }
            if *s as libc::c_int == ';' as i32 {
                s = s.offset(1);
            }
        }
    }
    if bad != 0 {
        log_debug(b"bad OSC 104: %s\0" as *const u8 as *const libc::c_char, p);
    }
    if redraw != 0 {
        screen_write_fullredraw(&mut (*ictx).ctx);
    }
    free(copy as *mut libc::c_void);
}
#[no_mangle]
pub unsafe extern "C" fn input_reply_clipboard(
    mut bev: *mut bufferevent,
    mut buf: *const libc::c_char,
    mut len: size_t,
    mut end: *const libc::c_char,
) {
    let mut out: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut outlen: libc::c_int = 0 as libc::c_int;
    if !buf.is_null() && len != 0 as libc::c_int as libc::c_ulong {
        if len
            >= (2147483647 as libc::c_int as size_t)
                .wrapping_mul(3 as libc::c_int as libc::c_ulong)
                .wrapping_div(4 as libc::c_int as libc::c_ulong)
                .wrapping_sub(1 as libc::c_int as libc::c_ulong)
        {
            return;
        }
        outlen = (4 as libc::c_int as libc::c_ulong)
            .wrapping_mul(
                len.wrapping_add(2 as libc::c_int as libc::c_ulong)
                    .wrapping_div(3 as libc::c_int as libc::c_ulong),
            )
            .wrapping_add(1 as libc::c_int as libc::c_ulong) as libc::c_int;
        out = xmalloc(outlen as size_t) as *mut libc::c_char;
        outlen = __b64_ntop(buf as *const libc::c_uchar, len, out, outlen as size_t);
        if outlen == -(1 as libc::c_int) {
            free(out as *mut libc::c_void);
            return;
        }
    }
    bufferevent_write(
        bev,
        b"\x1B]52;;\0" as *const u8 as *const libc::c_char as *const libc::c_void,
        6 as libc::c_int as size_t,
    );
    if outlen != 0 as libc::c_int {
        bufferevent_write(bev, out as *const libc::c_void, outlen as size_t);
    }
    bufferevent_write(bev, end as *const libc::c_void, strlen(end));
    free(out as *mut libc::c_void);
}
#[no_mangle]
pub unsafe extern "C" fn input_set_buffer_size(mut buffer_size: size_t) {
    log_debug(
        b"%s: %lu -> %lu\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 22], &[libc::c_char; 22]>(b"input_set_buffer_size\0"))
            .as_ptr(),
        input_buffer_size,
        buffer_size,
    );
    input_buffer_size = buffer_size;
}
